<template>
    <view class="container" :style="{ height: scrollHeight + 'px' }">
        <!--自定义头部状态栏-->
        <!-- #ifdef APP-PLUS -->
        <view class="status_bar"><view class="top_view"></view></view>
        <!-- #endif -->
        <view class="header">
            <view class="left u-m-l-10" @click="leftClick">
                <u-icon color="#fff" name="arrow-left" size="38"></u-icon>
                <slot name="left"></slot>
            </view>
            <view class="right-icon">
                <view class="u-relative" @click="scanCode"><u-icon name="scan" color="#fff" size="40"></u-icon></view>
                <view class="u-relative">
                    <image @click="wdfk" src="../../static/HM-chat/icon_wdfk.png"></image>
                    <u-badge v-if="myAllAsk && myAllAsk.length > 0" :offset="[-10, -10]" :is-dot="false" :count="myAllAsk.length" type="error"></u-badge>
                </view>
                <view class="u-relative" @click="msg">
                    <image src="../../static/HM-chat/icon_message.png"></image>
                    <u-badge v-if="unReadMsg > 0" :offset="[-10, -10]" :is-dot="false" :count="unReadMsg" type="error"></u-badge>
                </view>
                <view @click="addMore" class="u-relative"><image src="../../static/HM-chat/icon_add.png"></image></view>
                <view @click="showEdit" class="u-relative">
                    <image src="../../static/HM-chat/icon_menu.png"></image>
                    <u-badge v-if="unReadMsgNum.length > 0" :offset="[-10, -10]" :is-dot="true" type="error"></u-badge>
                </view>
            </view>
        </view>

        <u-read-more
            class="moredown"
            style="width: 100%; overflow: hidden"
            :toggle="toggle"
            show-height="150"
            ref="uReadMore"
            @open="showMsg = false"
            @close="closeMore()"
            :closeText="teamName"
            open-text=""
            right="-right"
            color="#fff"
            :shadowStyle="{
                justifyContent: 'space-between',
                textIndent: '15rpx',
                lineHeight: '50rpx'
            }"
        >
            <view class="team u-flex u-flex-col" style="position: relative; justify-content: flex-end">
                <view style="width: 100%" class="u-flex u-row-center">
                    <view @click="showLeft"><image style="width: 48rpx; height: 48rpx" src="../../static/HM-chat/more.png"></image></view>
                    <view style="width: 700rpx" class="u-flex u-flex-wrap">
                        <view
                            v-if="toUserId && toUserId == item.id"
                            @click="getMsgUserId(item.id)"
                            class="f-logo u-flex u-line-1"
                            v-for="(item, u) in showdetailList"
                            :key="'a' + u"
                            :style="{ backgroundImage: 'url(' + activeTeamMask + ')' }"
                        >
                            <text>{{ item.name }}</text>
                            <view class="tip" v-if="item.lockFlag && checkLeader">锁</view>
                            <view class="tip" v-if="item.shieldFlag && checkLeader">屏</view>
                            <view class="tip-t" v-if="item.fromTeamId">团</view>
                        </view>
                        <view
                            v-if="item.id > 0 && toUserId != item.id"
                            @click="getMsgUserId(item.id)"
                            class="f-logo u-line-1"
                            v-for="(item, index) in showdetailList"
                            :key="item.id"
                            :style="{ backgroundImage: 'url(' + teamMask + ')' }"
                        >
                            <text>{{ item.name }}</text>
                            <u-badge v-if="type == 999" :is-dot="true" :offset="[0, 0]" type="error" v-show="isUnRead('999__' + item.id)"></u-badge>
                            <u-badge v-else :is-dot="true" :offset="[0, 0]" type="error" v-show="isUnRead(type + '_' + teamId + '_' + item.id)"></u-badge>
                            <view class="tip" v-if="item.lockFlag && checkLeader">锁</view>
                            <view class="tip" v-if="item.shieldFlag && checkLeader">屏</view>
                            <view class="tip-t" v-if="item.fromTeamId">团</view>
                        </view>
                        <!--团队展开-->
                        <view
                            v-if="0 === item.id"
                            class="f-logo u-line-1"
                            v-for="(item, index) in showdetailList"
                            :key="index"
                            :style="{ backgroundImage: 'url(' + teamMask + ')' }"
                        >
                            <text>{{ item.name }}</text>
                            <u-badge v-if="type == 999" :is-dot="true" :offset="[0, 0]" type="error" v-show="isUnRead('999__' + item.id)"></u-badge>
                            <u-badge v-else :is-dot="true" :offset="[0, 0]" type="error" v-show="isUnRead(type + '_' + teamId + '_' + item.id)"></u-badge>
                            <view class="tip" v-if="item.lockFlag && checkLeader">锁</view>
                            <view class="tip" v-if="item.shieldFlag && checkLeader">屏</view>
                            <view class="tip-t" v-if="item.fromTeamId">团</view>
                        </view>

                        <!--团队展开-->
                        <view v-if="teamUser.length > 3" @click="changeFoldState" class="f-logo u-line-1" :style="{ backgroundImage: 'url(' + teamMask + ')' }">
                            <text>{{ userText }}</text>
                        </view>
                        <!--  <view v-if="hideTeamMember" @click="backGroup" class="f-logo u-line-1" :style="{ backgroundImage: 'url(' + teamMask + ')' }"><text>返回</text></view> -->
                        <view v-if="type != 999" class="f-logo" @click="inviteFriends"><image src="../../static/HM-chat/addteam.png"></image></view>
                        <!-- <view class="f-logo" @click="getQrcode()">
						<image src="../../static/HM-chat/all.png"></image>
					</view> -->
                        <!--<view v-if="teamUser.length > 8" @click="changeFoldState" class="f-logo">
						<image src="../../static/HM-chat/all.png"></image>
					</view> -->
                    </view>
                </view>
                <!-- <view style="width:100%;text-align: right;" @click="showuToast"><image style="width:48rpx;height:48rpx;margin-right:20rpx;" src="../../static/HM-chat/icon_down.png"></image></view> -->
                <block v-if="type != 999">
                    <chat-setting
                        :code="groupCode"
                        :leader="checkLeader"
                        :group="isGroup"
                        :id="groupId"
                        :user="toUserId"
                        :datas="settings"
                        :setUser="setUser"
                        :userSetting="userSetting"
                        @click="setting"
                        :key="settingKey"
                        @getQrcode="getQrcode"
                    ></chat-setting>
                    <view style="color: #fff" @click="report(1)">被骚扰了？举报该群</view>
                </block>
                <block v-else><view style="height: 50rpx"></view></block>
                <!-- <u-read-more v-else class="moredown" style="width:100%;overflow: hidden;" show-height="1" ref="uReadMore"
			 closeText="" open-text="" right="-right" color="#fff" :shadowStyle="{justifyContent : 'flex-end' }"></u-read-more> -->
            </view>
        </u-read-more>
        <view v-show="showMsg" class="content" :style="{ top: contentTop + 'px', height: contentHeight + 'px' }" @touchstart="hideDrawer">
            <scroll-view
                class="msg-list"
                :scroll-y="true"
                :style="{ height: contentHeight + 'px' }"
                :scroll-with-animation="scrollAnimation"
                :scroll-top="scrollTop"
                :scroll-into-view="scrollToView"
                upper-threshold="50"
            >
                <!-- 加载历史数据waitingUI -->
                <view class="loading">
                    <view v-bind:class="{ spinnerhide: isSpinnerhide, spinner: isSpinner }">
                        <view class="rect1"></view>
                        <view class="rect2"></view>
                        <view class="rect3"></view>
                        <view class="rect4"></view>
                        <view class="rect5"></view>
                    </view>
                </view>
                <view
                    v-if="msgList != undefined && msgList != ''"
                    class="row u-m-l-20 u-m-r-20"
                    v-for="(row, index) in msgList"
                    :key="index"
                    :id="row.msg != undefined ? 'msg' + row.msg.chatId : ''"
                >
                    <view v-if="row.type != ''" class="u-m-b-20">
                        <!-- 系统消息 -->
                        <block v-if="row.type == 'system'">
                            <view class="system">
                                <!-- 文字消息 -->
                                <view v-if="row.msg.type == 'text'" class="text">
                                    <view
                                        style="
                      display: flex;
                      align-items: center;
                      word-wrap: break-word;
                      flex-wrap: wrap;
                    "
                                        v-html="row.msg.content.text"
                                    ></view>
                                </view>
                            </view>
                        </block>
                        <!-- 用户消息 -->
                        <block v-if="row.type == 'chat'">
                            <!-- 自己发出的消息 -->
                            <view class="my" v-if="row.msg.from == userinfo.id">
                                <!-- 左-消息 -->
                                <view class="left">
                                    <view class="username">
                                        <view class="time">{{ row.msg.time }}</view>
                                    </view>
                                    <!-- 文字消息 -->
                                    <view v-if="row.msg.type == 'text'" class="bubble">
                                        <rich-text
                                            style="
                        display: flex;
                        align-items: center;
                        word-wrap: break-word;
                        flex-wrap: wrap;
                      "
                                            :nodes="row.msg.content"
                                        ></rich-text>
                                    </view>
                                    <view v-if="row.msg.type == 'HB'" :class="[row.msg.status == 0 ? 'hb-box' : 'hb-box-op']" @tap="hbDetail(row.msg.id)">
                                        <rich-text
                                            style="
                        display: flex;
                        align-items: center;
                        word-wrap: break-word;
                        flex-wrap: wrap;
                      "
                                            :nodes="row.msg.content"
                                        ></rich-text>
                                    </view>
                                    <view v-if="row.msg.type == 'notice'" :class="[row.msg.status == 1 ? 'notice-box' : 'notice-box-op']">
                                        <rich-text
                                            style="
                        display: flex;
                        align-items: center;
                        word-wrap: break-word;
                        flex-wrap: wrap;
                      "
                                            :nodes="row.msg.content"
                                        ></rich-text>
                                        <view class="access-btn">
                                            <text v-if="row.msg.status == 1">已确认</text>
                                            <text v-else>确认</text>
                                        </view>
                                    </view>
                                    <view
                                        v-if="row.msg.type == 'inquiry'"
                                        :class="[row.msg.status == 1 ? 'notice-box' : 'notice-box-op']"
                                        @click="handleClickInquiryShow(row.msg.id)"
                                    >
                                        <rich-text
                                            style="
                        display: flex;
                        align-items: center;
                        word-wrap: break-word;
                        flex-wrap: wrap;
                      "
                                            :nodes="row.msg.content"
                                        ></rich-text>
                                        <view class="access-btn">
                                            <text v-if="row.msg.status == 1">已报价</text>
                                            <text v-else>报价</text>
                                        </view>
                                    </view>

                                    <!-- 语言消息 -->
                                    <view v-if="row.msg.type == 'voice'" class="bubble voice" @tap="playVoice(row.msg)" :class="playMsgid == row.msg.chatId ? 'play' : ''">
                                        <view class="length">{{ row.msg.content.length }}</view>
                                        <view class="icon my-voice"></view>
                                    </view>
                                    <!-- 图片消息 -->
                                    <view v-if="row.msg.type == 'img'" class="bubble img" @tap="showPic(row.msg)">
                                        <image
                                            :src="row.msg.content.url"
                                            :style="{
                                                width: row.msg.content.w + 'px',
                                                height: row.msg.content.h + 'px'
                                            }"
                                        ></image>
                                    </view>
                                </view>
                                <!-- 右-头像 -->
                                <view class="right chat-avatar" @click="toHomePage(row.msg.from)">
                                    <image :src="logoMask" mode="aspectFill"></image>
                                    <text class="u-line-1">{{ row.msg.fromName }}</text>
                                </view>
                            </view>
                            <!-- 别人发出的消息 -->
                            <view class="other" v-if="row.msg.from != undefined && row.msg.from != userinfo.id">
                                <!-- 左-头像 -->
                                <view class="left chat-avatar" @click="toHomePage(row.msg.from)">
                                    <text class="u-line-1">{{ row.msg.fromName }}</text>
                                    <image :src="logoMask" mode="aspectFill"></image>
                                </view>
                                <!-- 右-用户名称-时间-消息 -->
                                <view class="right">
                                    <view class="username">
                                        <view class="time">{{ row.msg.time }}</view>
                                    </view>
                                    <!-- 文字消息 -->
                                    <view v-if="row.msg.type != 'goods'">
                                        <view v-if="row.msg.type == 'text'" class="bubble">
                                            <rich-text
                                                style="
                          display: flex;
                          align-items: center;
                          word-wrap: break-word;
                          flex-wrap: wrap;
                        "
                                                :nodes="row.msg.content"
                                            ></rich-text>
                                        </view>
                                    </view>
                                    <view v-if="row.msg.type == 'HB'" :class="[row.msg.status == 1 ? 'hb-box' : 'hb-box-op']" @tap="hbDetail(row.msg.id)">
                                        <rich-text
                                            style="
                        display: flex;
                        align-items: center;
                        word-wrap: break-word;
                        flex-wrap: wrap;
                      "
                                            :nodes="row.msg.content"
                                        ></rich-text>
                                    </view>
                                    <view v-if="row.msg.type == 'notice'" :class="[row.msg.status == 1 ? 'notice-box' : 'notice-box-op']" @tap="noticeDetail(row.msg.id)">
                                        <rich-text
                                            style="
                        display: flex;
                        align-items: center;
                        word-wrap: break-word;
                        flex-wrap: wrap;
                      "
                                            :nodes="row.msg.content"
                                        ></rich-text>
                                        <view class="access-btn">
                                            <text v-if="row.msg.status == 1">已确认</text>
                                            <text v-else>确认</text>
                                        </view>
                                    </view>
                                    <view
                                        v-if="row.msg.type == 'inquiry'"
                                        :class="[row.msg.status == 1 ? 'notice-box' : 'notice-box-op']"
                                        @click="handleClickInquiryShow(row.msg.id)"
                                    >
                                        <rich-text
                                            style="
                        display: flex;
                        align-items: center;
                        word-wrap: break-word;
                        flex-wrap: wrap;
                      "
                                            :nodes="row.msg.content"
                                        ></rich-text>
                                        <view class="access-btn">
                                            <text v-if="row.msg.status == 1">已报价</text>
                                            <text v-else>报价</text>
                                        </view>
                                    </view>
                                    <!-- 语音消息 -->
                                    <view v-if="row.msg.type == 'voice'" class="bubble voice" @tap="playVoice(row.msg)" :class="playMsgid == row.msg.chatId ? 'play' : ''">
                                        <view class="icon other-voice"></view>
                                        <view class="length">{{ row.msg.content.length }}</view>
                                    </view>
                                    <!-- 图片消息 -->
                                    <view v-if="row.msg.type == 'img'" class="bubble img" @tap="showPic(row.msg)">
                                        <image
                                            :src="row.msg.content.url + '?imageView2/2/w/350'"
                                            :style="{
                                                width: row.msg.content.w + 'px',
                                                height: row.msg.content.h + 'px'
                                            }"
                                        ></image>
                                    </view>
                                </view>
                            </view>
                        </block>
                    </view>
                </view>
            </scroll-view>
        </view>
        <!-- 抽屉栏 -->
        <view class="popup-layer" :class="popupLayerClass" @touchmove.stop.prevent="discard">
            <!-- 表情 -->
            <swiper class="emoji-swiper" :class="{ hidden: hideEmoji }" indicator-dots="true" duration="150">
                <swiper-item v-for="(page, pid) in emojiList" :key="pid">
                    <view v-for="(em, eid) in page" :key="eid" @tap="addEmoji(em)"><image mode="widthFix" :src="'../../static/img/emoji/' + em.url"></image></view>
                </swiper-item>
            </swiper>
            <!-- 更多功能 相册-拍照-红包 -->
            <view class="more-layer" :class="{ hidden: hideMore }">
                <view class="list">
                    <view class="box" @tap="chooseImage"><view class="icon tupian2"></view></view>
                    <view class="box" @tap="camera"><view class="icon paizhao"></view></view>
                    <view class="box voice"><view class="icon" :class="isVoice ? 'jianpan' : 'yuyin'" @tap="switchVoice"></view></view>

                    <!-- <view class="box" @tap="handRedEnvelopes"><view class="icon hongbao"></view></view> -->
                </view>
            </view>
        </view>
        <!-- 底部输入栏 -->
        <view class="input-box" :class="popupLayerClass" @touchmove.stop.prevent="discard">
            <!-- H5下不能录音，输入栏布局改动一下 -->
            <view class="more" @click="showDetial"><image style="width: 48rpx; height: 48rpx" src="../../static/HM-chat/edit.png"></image></view>
            <view class="textbox">
                <view
                    class="voice-mode"
                    :class="[isVoice ? '' : 'hidden', recording ? 'recording' : '']"
                    @touchstart="voiceBegin"
                    @touchmove.stop.prevent="voiceIng"
                    @touchend="voiceEnd"
                    @touchcancel="voiceCancel"
                >
                    {{ voiceTis }}
                </view>
                <view class="text-mode" :class="isVoice ? 'hidden' : ''">
                    <view class="box"><textarea auto-height="true" v-model="textMsg" @focus="textareaFocus" /></view>
                    <view class="em" @tap="chooseEmoji"><image style="width: 48rpx; height: 48rpx" src="../../static/HM-chat/face.png"></image></view>
                </view>
            </view>
            <view class="more" @tap="showMore"><image style="width: 48rpx; height: 48rpx" src="../../static/HM-chat/add.png"></image></view>
            <view class="send" :class="isVoice ? 'hidden' : ''" @tap="sendText"><view class="btn">发送</view></view>
        </view>
        <view class="wx-menu">
            <text @click="showuToast">我的收藏</text>
            <text :class="{ hover: showWdfq == false }">即时交流</text>
            <text class="wdfx" :class="{ hover: showWdfq == true }" @click="showWdfq = !showWdfq">我的发起</text>
            <text @click="fbh">我的发布号</text>
        </view>
        <view class="wdfq" v-show="showWdfq" :style="{ right: marginRight + 'rpx' }">
            <view
                @click="
                    showQrfq = true;
                    showWdfq = false;
                "
            >
                <image src="../../static/HM-chat/menu_qrfq.png"></image>
                <text>确认发起</text>
            </view>
            <view
                @click="
                    showHB = true;
                    showWdfq = false;
                "
            >
                <image src="../../static/HM-chat/menu_wdhb.png"></image>
                <text>我的红包</text>
            </view>
            <view v-if="type == 4 || type == 11" @click="showViewpoints">
                <image src="../../static/HM-chat/menu_wdgd.png"></image>
                <text>我的观点</text>
            </view>
            <view @click="showPay">
                <image src="../../static/HM-chat/menu_wdzf.png"></image>
                <text>我的支付</text>
            </view>
            <view @click="showArbitrations">
                <image src="../../static/HM-chat/menu_wdzc.png"></image>
                <text>我的仲裁</text>
            </view>
            <view @click="showToast">
                <image src="../../static/HM-chat/menu_wdbp.png"></image>
                <text>我的评标</text>
            </view>
            <view
                @click="
                    showInquiry = true;
                    showWdfq = false;
                "
            >
                <image src="../../static/HM-chat/menu_fb.png"></image>
                <text>询价发布</text>
            </view>
        </view>
        <view class="mark" @click="showWdfq = false" v-show="showWdfq"></view>
        <!-- 录音UI效果 -->
        <view class="record" :class="recording ? '' : 'hidden'">
            <view class="ing" :class="willStop ? 'hidden' : ''"><view class="icon luyin2"></view></view>
            <view class="cancel" :class="willStop ? '' : 'hidden'"><view class="icon chehui"></view></view>
            <view class="tis" :class="willStop ? 'change' : ''">{{ recordTis }}</view>
        </view>
        <!--右边主菜单-->
        <u-popup border-radius="0" v-model="show" @close="close" @open="open" :mode="mode" length="50%" :mask="mask" :closeable="closeable" :close-icon-pos="closeIconPos">
            <view class="u-flex u-flex-wrap left-menu u-m-t-80 u-p-30" v-if="showQr == true">
                <view class="left-head">
                    <image :src="category.icon"></image>
                    <text>{{ category.title }}</text>
                </view>
                <scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" style="width: 92%; height: 60vh; text-align: left; line-height: 60rpx">
                    <u-checkbox-group @change="checkboxGroupChange" :width="radioCheckWidth" :wrap="radioCheckWrap">
                        <u-checkbox v-model="item.checked" v-for="(item, index) in myAllAsk" :key="index" :name="item.id" class="u-m-t-20">
                            <view class="u-line-1" style="width: 250rpx">{{ item.userName }}</view>
                        </u-checkbox>
                    </u-checkbox-group>
                </scroll-view>
                <view @click="agree(1)" class="btn-agree">同意</view>
                <view @click="agree" class="btn-agree u-m-t-20" style="background-color: #f29100">拒绝</view>
            </view>
            <view class="u-flex u-flex-wrap m-menu u-m-t-50" v-else>
                <view @click="showLeft(1, '智汇团队', '../../static/HM-chat/zhtd.png')" url="../notepad/zhihuiTeam/leagueMemberTwo" class="item">
                    <image src="../../static/HM-chat/zhtd.png"></image>
                    <text>智汇团队</text>
                    <u-badge :is-dot="true" :absolute="false" type="error" v-show="isUnRead('1_', 1)"></u-badge>
                </view>
                <view @click="showLeft(2, '智汇N+1', '../../static/HM-chat/zhn1.png')" url="../notepad/zhihuin1/index" class="item">
                    <image src="../../static/HM-chat/zhn1.png"></image>
                    <text>智汇N+1</text>
                    <u-badge :is-dot="true" :absolute="false" type="error" v-show="isUnRead('2_', 2)"></u-badge>
                </view>
                <view @click="showLeft(3, '智汇公社', '../../static/HM-chat/zhgs.png')" url="../notepad/communication/zhihuiCommune" class="item">
                    <image src="../../static/HM-chat/zhgs.png"></image>
                    <text>智汇公社</text>
                    <u-badge :is-dot="true" :absolute="false" type="error" v-show="isUnRead('3_', 3)"></u-badge>
                </view>
                <view @click="showLeft(10, '智汇大脑', '../../static/HM-chat/zhdn.png')" url="../notepad/communication/zhihuiLearning" class="item">
                    <image src="../../static/HM-chat/zhdn.png"></image>
                    <text>智汇大脑</text>
                    <u-badge :is-dot="true" :absolute="false" type="error" v-show="isUnRead('10_', 10)"></u-badge>
                </view>
                <view @click="showChild('zhfb')" url="../notepad/communication/zhihuirelease" class="item u-flex u-row-between" style="align-items: center">
                    <view class="u-flex u-row-center">
                        <image src="../../static/HM-chat/zhfb.png"></image>
                        <text>智汇发布</text>
                    </view>
                    <u-icon name="arrow-right" size="28" color="#909399" class="u-m-r-20" :class="{ down: child === 'zhfb' }"></u-icon>
                </view>
                <view class="child" v-if="child == 'zhfb'">
                    <view class="p25" @click="showLeft(12, '智汇服务', '../../static/HM-chat/zhfb.png')">
                        智汇服务
                        <u-badge :is-dot="true" :absolute="false" type="error" v-show="isUnRead('12_', -1)"></u-badge>
                    </view>
                    <view class="p25" @click="showLeft(7, '智汇信息', '../../static/HM-chat/zhfb.png')">
                        智汇信息
                        <u-badge :is-dot="true" :absolute="false" type="error" v-show="isUnRead('7_', -1)"></u-badge>
                    </view>
                    <view class="p25" @click="showLeft(8, '智汇推广', '../../static/HM-chat/zhfb.png')">
                        智汇推广
                        <u-badge :is-dot="true" :absolute="false" type="error" v-show="isUnRead('8_', -1)"></u-badge>
                    </view>
                    <view class="p25" @click="showLeft(9, '智汇活动', '../../static/HM-chat/zhfb.png')">
                        智汇活动
                        <u-badge :is-dot="true" :absolute="false" type="error" v-show="isUnRead('9_', -1)"></u-badge>
                    </view>
                    <view class="p25" @click="showLeft(13, '积微成著', '../../static/HM-chat/zhfb.png')">
                        积微成著
                        <u-badge :is-dot="true" :absolute="false" type="error" v-show="isUnRead('13_', -1)"></u-badge>
                    </view>
                </view>
                <view @click="showChild('zhzyp')" url="../notepad/communication/zhihuiRecruitment" class="item u-flex u-row-between" style="align-items: center">
                    <view class="u-flex u-row-center">
                        <image src="../../static/HM-chat/zhzp.png"></image>
                        <text>智汇招聘</text>
                    </view>
                    <u-icon name="arrow-right" size="28" color="#909399" class="u-m-r-20" :class="child == 'zhzyp' ? 'down' : ''"></u-icon>
                </view>
                <view class="child" v-if="child == 'zhzyp'">
                    <view class="p25" @click="showLeft(5, '智汇招聘', '../../static/HM-chat/zhzp.png')">
                        <text class="u-m-r-10">智汇招聘</text>
                        <u-badge :is-dot="true" :absolute="false" type="error" v-show="isUnRead('5_', 5)"></u-badge>
                    </view>
                    <view class="p25" @click="showLeft(6, '智汇应聘', '../../static/HM-chat/zhzp.png')">
                        <text class="u-m-r-10">智汇应聘</text>
                        <u-badge :is-dot="true" :absolute="false" type="error" v-show="isUnRead('6_', 6)"></u-badge>
                    </view>
                </view>
                <view @click="showChild('wdxm')" url="../notepad/communication/myProject" class="item u-flex u-row-between" style="align-items: center">
                    <view class="u-flex u-row-center">
                        <image src="../../static/HM-chat/wdxm.png"></image>
                        <text>我的项目</text>
                    </view>
                    <u-icon name="arrow-right" size="28" color="#909399" class="u-m-r-20" :class="child == 'wdxm' ? 'down' : ''"></u-icon>
                </view>
                <view class="child" v-if="child == 'wdxm'">
                    <view class="p25" @click="showLeft(4, '工程信息', '../../static/HM-chat/wdxm.png')">
                        <text class="u-m-r-10">工程信息</text>
                        <u-badge :is-dot="true" :absolute="false" type="error" v-show="isUnRead('4_', 4)"></u-badge>
                    </view>
                    <view class="p25" @click="showLeft(11, '招投标', '../../static/HM-chat/wdxm.png')">
                        <text class="u-m-r-10">招投标</text>
                        <u-badge :is-dot="true" :absolute="false" type="error" v-show="isUnRead('11_', 11)"></u-badge>
                    </view>
                </view>
                <view class="item" @click="tempChat">
                    <image src="../../static/HM-chat/lsjl.png"></image>
                    <text>临时交流</text>
                    <u-badge :is-dot="true" :absolute="false" type="error" v-show="isUnRead('999_', 999)"></u-badge>
                </view>
            </view>
        </u-popup>
        <!--左边团队列表菜单-->
        <u-popup border-radius="0" v-model="showL" :mode="modeLeft" :length="leftLength" :mask="mask" :closeable="closeable" :close-icon-pos="closeIconPos">
            <view class="u-flex u-flex-wrap left-menu u-m-t-80">
                <view class="left-head u-m-b-30">
                    <image :src="category.icon"></image>
                    <text>{{ category.title }}</text>
                </view>
                <view v-if="tmpType < 4" v-for="(item, index) in myTeams" :key="index" @click="getTeamUser(item)" class="f-logo u-flex u-col-center">
                    <text class="u-line-2">{{ item.name }}</text>
                    <image :src="item.id == detailId ? activeTeamMask : logoMask" mode="aspectFill"></image>
                    <u-badge :is-dot="true" :offset="[0, 0]" type="error" v-show="isUnRead(item.groupType + '_' + item.id)"></u-badge>
                </view>
                <view v-if="tmpType > 3" v-for="(item, idx) in myTeams" :key="'a' + idx" @click="getTeamUser(item)" class="f-list u-border-bottom u-flex u-col-center">
                    <u-badge :is-dot="true" :offset="[0, 0]" type="error" v-show="isUnRead(item.groupType + '_' + item.id)"></u-badge>
                    <text class="u-line-2" :class="{ active: item.id == detailId }">{{ item.name }}</text>
                </view>
            </view>
        </u-popup>
        <!--底部弹出红包窗口-->
        <u-popup border-radius="0" v-model="showHB" :mode="modeBottom" :mask="mask" :closeable="closeable" :close-icon-pos="closeIconPos">
            <view style="overflow: auto; background-color: #fff" :style="{ height: scrollHeight - 50 + 'px' }"><Hongbao @click="handleClickSave"></Hongbao></view>
        </u-popup>
        <!--底部弹出我的观点窗口-->
        <u-popup border-radius="0" v-model="showViewpoint" :mode="modeBottom" :mask="mask" :closeable="closeable" :close-icon-pos="closeIconPos">
            <view style="overflow: auto" :style="{ height: scrollHeight - 50 + 'px' }">
                <m-viewpoint-detail v-if="viewpoint.viewed" :datas="viewpoint" @click="handleClickViewpoint"></m-viewpoint-detail>
                <m-viewpoint v-else :datas="myViewpoint" :curror="viewpointCurror" @click="handleClickViewpoint"></m-viewpoint>
            </view>
        </u-popup>
        <!--底部弹出我的询价窗口-->
        <u-popup border-radius="0" v-model="showInquiry" :mode="modeBottom" :mask="mask" :closeable="closeable" :close-icon-pos="closeIconPos" :safe-area-inset-bottom="true">
            <view style="overflow: auto; background-color: #fff" :style="{ height: scrollHeight - 50 + 'px' }">
                <m-inquiry :datas="myInquiry" @click="handleClickInquiry"></m-inquiry>
            </view>
        </u-popup>
        <!--底部弹出仲裁窗口-->
        <u-popup border-radius="0" v-model="showArbitration" :mode="modeBottom" :mask="mask" :closeable="closeable" :close-icon-pos="closeIconPos">
            <view style="overflow: auto; background-color: #fff" :style="{ height: scrollHeight - 50 + 'px' }">
                <m-arbitration v-if="project !== ''" :datas="myProject" @click="handleClickArbitration"></m-arbitration>
                <m-arbitration-detail v-else :datas="project"></m-arbitration-detail>
            </view>
        </u-popup>
        <!--底部弹出支付窗口-->
        <u-popup border-radius="0" v-model="openPay" :mode="modeBottom" :mask="mask" :closeable="closeable" :close-icon-pos="closeIconPos">
            <view style="overflow: auto; background-color: #fff" :style="{ height: scrollHeight - 50 + 'px' }"><m-pay :datas="myProject" @click="handleClickPay"></m-pay></view>
        </u-popup>
        <!--底部弹出好友窗口-->
        <u-popup border-radius="0" v-model="showFriends" :mode="modeBottom" :mask="mask" :closeable="false" :close-icon-pos="closeIconPos">
            <view style="overflow: auto; background-color: #e8e9eb" :style="{ height: scrollHeight - 100 + 'px' }">
                <view class="u-m-30">
                    <u-search
                        :clearabled="false"
                        :show-action="true"
                        action-text="搜索"
                        :action-style="actionStyle"
                        @custom="searchFriend"
                        placeholder="个人编号/团队"
                        :animation="true"
                    ></u-search>
                </view>
                <view class="friend-list" v-if="friendList != ''">
                    <view class="item" v-for="(item, index) in friendList" :key="index">
                        <view class="left">
                            <view
                                class="f-logo"
                                v-if="item.logo != ''"
                                :style="{
                                    backgroundImage: 'url(' + (item.logo != null ? baseUrl + item.logo : defaultLogo) + ')'
                                }"
                            >
                                <image :src="logoMask" mode="aspectFill"></image>
                            </view>
                            <view v-else class="f-logo team-logo" :style="{ backgroundImage: 'url(' + logoMask + ')' }">
                                <text class="u-line-2">{{ item.name }}</text>
                            </view>
                        </view>
                        <view class="center">
                            <view class="title">{{ item.name }}</view>
                            <view
                                class="tag"
                                :class="{
                                    tag2: item.userType === 1,
                                    tag3: item.userType === 0
                                }"
                            >
                                {{ item.userType === 10 ? '团队' : item.userType === 0 ? '个人' : '企业' }}
                            </view>
                        </view>
                        <view class="right"><view class="btn" @click="handleClickFriend(item)">邀请</view></view>
                    </view>
                </view>
                <view v-else class="u-flex u-row-center u-m-50" style="flex-direction: column">
                    <image style="width: 300rpx; height: 300rpx" mode="widthFix" src="../../static/img/nog.png"></image>
                    <text style="color: #ccc">找人/团队</text>
                </view>
                <!-- <m-friend :datas="myFriends" @click="handleClickFriend"></m-friend> -->
            </view>
        </u-popup>

        <!--底部弹出我的发起窗口-->
        <u-select mode="single-column" :list="qrfqList" v-model="showQrfq" @confirm="confirmQrfq"></u-select>
        <!--输入提醒框-->
        <u-popup width="600" v-model="popupActive" mode="center">
            <view class="view-popup">
                <view style="margin-bottom: 20upx" v-if="noticeType == '事项提醒'">常用提醒:</view>
                <view class="tagCustom" v-if="noticeType == '事项提醒'">
                    <text :class="{ on: noticeTitle == '函件确认' }" @click="setInputCustom('函件确认', '函件发出，请确认+确认收到文件')">函件确认</text>
                    <text :class="{ on: noticeTitle == '赴约提醒' }" @click="setInputCustom('赴约提醒', '准时赴约提醒，请确认+确认准时赴约')">赴约提醒</text>
                    <text :class="{ on: noticeTitle == '信息提交' }" @click="setInputCustom('信息提交', '信息已经提交，请确认+确认收到信息')">信息提交</text>
                    <text :class="{ on: noticeTitle == '资金确认' }" @click="setInputCustom('资金确认', '资金已转，请确认+确认收到资金')">资金确认</text>
                    <text :class="{ on: noticeTitle == '自定义' }" @click="setInputCustom('', '')">自定义</text>
                </view>
                <view style="margin-bottom: 20upx" v-if="noticeType != '事项提醒'">{{ noticeType }}:</view>
                <u-input class="u-m-t-20 u-m-b-20" v-model="noticeTitle" placeholder="请输入提醒标题" :border="true" />
                <u-input type="textarea" v-model="noticeContent" placeholder="请输入提醒内容" :border="true" />
                <view style="display: flex; margin-top: 20upx">
                    <u-button style="height: 60upx" @click="handleAddTag" type="primary">确认</u-button>
                    <u-button style="height: 60upx" @click="popupActive = false">取消</u-button>
                </view>
            </view>
        </u-popup>
        <!--询价报价-->
        <u-popup v-model="inquiryShow" mode="center" length="90%" :closeable="true">
            <view class="view-popup">
                <block v-if="inquiryItems.type == 1">
                    <view class="tdmc u-border-bottom u-m-l-30">
                        <text>询价类型</text>
                        <text class="right">工程询价</text>
                    </view>
                    <view class="tdmc u-border-bottom u-m-l-30">
                        <text>项目名称</text>
                        <text class="right">{{ inquiryItems.projectName }}</text>
                    </view>
                    <view class="tdmc u-border-bottom u-m-l-30">
                        <text>项目类型</text>
                        <text class="right">{{ inquiryItems.projectType }}</text>
                    </view>
                    <view class="tdmc u-border-bottom u-m-l-30">
                        <text>项目阶段</text>
                        <text class="right">{{ inquiryItems.projectStage }}</text>
                    </view>
                    <view class="u-m-l-30 tdmc u-border-bottom">
                        <text>项目规模</text>
                        <text class="right">{{ inquiryItems.projectScale }}平方米</text>
                    </view>
                    <view class="u-m-l-30 tdmc u-border-bottom">
                        <text>投资额</text>
                        <text class="right">{{ inquiryItems.investment }}万元</text>
                    </view>
                    <view class="u-m-l-30 tdmc u-border-bottom">
                        <text>项目地域</text>
                        <text class="right">{{ inquiryItems.projectRegion }}</text>
                    </view>
                    <view class="u-m-l-30 tdmc u-border-bottom">
                        <text>工作周期</text>
                        <text class="right">{{ inquiryItems.projectCycle }}个月</text>
                    </view>
                    <view class="u-m-l-30 tdmc u-border-bottom">
                        <text>项目报价</text>
                        <text class="right">{{ inquiryItems.projectQuoted }}万元</text>
                    </view>
                </block>
                <block v-else>
                    <view class="tdmc u-border-bottom u-m-l-30">
                        <text>询价类型</text>
                        <text class="right">采购询价</text>
                    </view>

                    <view class="tdmc u-border-bottom u-m-l-30">
                        <text>产品类型</text>
                        <text class="right">{{ inquiryItems.cplx }}</text>
                    </view>
                    <view class="tdmc u-border-bottom u-m-l-30">
                        <text>产品数量</text>
                        <text class="right">{{ inquiryItems.cpsl }}</text>
                    </view>

                    <view class="tdmc u-border-bottom u-m-l-30">
                        <text>产品规格</text>
                        <text class="right">{{ inquiryItems.cpgg }}</text>
                    </view>
                    <view class="tdmc u-border-bottom u-m-l-30">
                        <text>单价</text>
                        <text class="right">{{ inquiryItems.dj }}万元</text>
                    </view>
                </block>
                <view class="u-m-l-30 tdmc u-border-bottom">
                    <text>询价时效</text>
                    <text class="right">{{ inquiryItems.xjprescripte }}天</text>
                </view>
                <view class="u-m-l-30 tdmc u-border-bottom">
                    <text>发布时间</text>
                    <text class="right">{{ inquiryItems.createTime }}</text>
                </view>
                <view class="u-m-l-30 tdmc u-p-t-20" style="display: flex;align-items: center;">
                    <text>输入报价</text>
                    <u-input class="u-m-l-10 u-m-r-10" v-model="inquiryMoney" placeholder="请输入金额" :border="true" />
                    <u-button @click="inquiryDetail" type="primary">确认</u-button>
                </view>
            </view>
        </u-popup>
        <!--裂变公社二维码-->
        <u-popup border-radius="10" v-model="showQrcode" @close="close" @open="open" mode="center" length="90%" :mask="mask" :closeable="closeable" :close-icon-pos="closeIconPos">
            <view class="openbox" style="height: 900rpx">
                <view class="title">{{ category.title }}二维码</view>
                <view class="tips">下载【智汇方舟】并扫描，申请加入{{ category.title }}</view>
                <view class="qrcode"><image :src="baseUrl + qrcode"></image></view>
                <view class="number" @click="downLoadQrcode()">下载二维码</view>
            </view>
        </u-popup>

        <u-toast ref="uToast" />
        <view v-show="!showMsg" class="bottom-box"></view>
    </view>
</template>
<script>
import mRed from '@/components/m-red/m-red.vue';
import Hongbao from './red.vue';
import mPay from '@/components/m-pay/m-pay.vue';
import mArbitration from '@/components/m-arbitration/m-arbitration.vue';
import mArbitrationDetail from '@/components/m-arbitration/m-arbitration-detail.vue';
import mViewpoint from '@/components/m-viewpoint/m-viewpoint.vue';
import mViewpointDetail from '@/components/m-viewpoint/m-viewpoint-detail.vue';
import mInquiry from '@/components/m-inquiry/m-inquiry.vue';
import { emoji } from '@/config/emoji.js';
import utils from '@/common/utils.js';

export default {
    components: {
        mRed,
        mArbitration,
        mArbitrationDetail,
        mViewpoint,
        mViewpointDetail,
        mInquiry,
        mPay,
        Hongbao
    },
    computed: {
        showdetailList: {
            get: function() {
                console.log('diaoyongle');
                console.log(this.teamUser);

                if (this.openUsers) {
                    console.log('teamUser', this.teamUser);
                    if (this.teamUser.length < 4) {
                        return this.teamUser;
                    }
                    var newArr = [];
                    if (this.toUserId > 0) {
                        for (var i = 0; i < this.teamUser.length; i++) {
                            let item = this.teamUser[i];
                            if (item.id == this.toUserId) {
                                newArr.push(item);
                            }
                        }
                        for (var i = 0; i < 3; i++) {
                            let item = this.teamUser[i];
                            if (item.id != this.toUserId && newArr.length < 3) {
                                newArr.push(item);
                            }
                        }
                    } else {
                        for (var i = 0; i < 3; i++) {
                            let item = this.teamUser[i];
                            newArr.push(item);
                        }
                    }

                    return newArr;
                }

                return this.teamUser;
            },
            set: function(val) {
                this.showdetailList = val;
            }
        }
    },
    data() {
        return {
            inquiryItems: [],
            hideTeamMember: false, //是否显示嵌套团队展开按钮
            currentTeam: {},
            viewpointCurror: 0,
            teamName: '',
            actionStyle: {
                color: 'rgb(96, 98, 102)'
            },
            userText: '更多',
            friendList: '',
            baseUrl: this.$mConfig.baseUrl,
            qrcode: '',
            showMsg: true,
            groupCode: '',
            noticeType: '事项提醒',
            showCustom: false,
            openUsers: true,
            settingKey: 0,
            checkLeader: false,
            myFriends: [],
            showFriends: false,
            settings: {
                disturbFlag: false,
                groupName: '',
                lockFlag: false,
                meetingTime: 0,
                notice: '',
                removeFlag: false,
                shieldFlag: false,
                targetUserId: 0,
                teamChatId: ''
            },
            setUser: {},
            userSetting: {},
            unApplyMsg: 0,
            unReadMsg: 0,
            inquiryId: '',
            inquiryMoney: '',
            inquiryShow: false,
            showInquiry: false,
            showViewpoint: false,
            viewpoint: '',
            project: '',
            myProject: [],
            myViewpoint: [],
            myInquiry: [],
            showArbitration: false, //是否显示仲裁窗口
            openPay: false,
            noticeTitle: '',
            noticeContent: '',
            popupActive: false,
            isGroup: true,
            detailId: '',
            argeeIds: '',
            toUsername: '',
            myname: '我',
            showHB: false,
            modeBottom: 'bottom',
            showQrfq: false,
            qrfqList: [
                {
                    value: '事项提醒',
                    label: '事项提醒'
                },
                {
                    value: '预付款申请',
                    label: '预付款申请'
                },
                {
                    value: '付款申请',
                    label: '付款申请'
                },
                {
                    value: '退款申请',
                    label: '退款申请'
                },
                {
                    value: '终止合作',
                    label: '终止合作'
                }
            ],
            radioCheckWidth: '90%',
            radioCheckWrap: false,
            myAllAsk: [],
            showQr: false,
            height: 20,
            bgColor: this.$u.color.bgColor,
            marginTop: 20,
            marginBottom: 20,
            showHeight: 130,
            toggle: true,
            showWdfq: false,
            leftLength: '27%',
            child: '',
            groupId: '',
            toUserId: '',
            type: 1,
            tmpType: 1,
            teamId: '',
            myTeams: [],
            //右侧弹窗
            logoMask: this.$mAssetsPath.logoMask,
            teamMask: this.$mAssetsPath.teamMask,
            activeTeamMask: this.$mAssetsPath.activeTeamMask,
            defaultLogo: this.$mAssetsPath.defaultLogo,
            scrollHeight: 0,
            contentHeight: 0,
            contentTop: 0,
            marginRight: 0,
            userinfo: this.$store.state.userInfo,
            showL: false,
            modeLeft: 'left',
            show: false,
            mode: 'right',
            mask: true, // 是否显示遮罩
            closeable: true,
            closeIconPos: 'top-right',
            //文字消息
            goodsData: {},
            product: {},
            textMsg: '',
            //消息列表
            isHistoryLoading: false,
            scrollAnimation: false,
            scrollTop: 0,
            scrollToView: '',
            msgList: [],
            msgImgList: [],
            msgloalhost: [],
            myuid: 0,
            socketOpen: false,
            mcount: 0,
            isSpinnerhide: true,
            isSpinner: false,
            //录音相关参数
            // #ifndef H5
            //H5不能录音
            RECORDER: uni.getRecorderManager(),
            // #endif
            isVoice: false,
            voiceTis: '按住 说话',
            recordTis: '手指上滑 取消发送',
            recording: false,
            willStop: false,
            initPoint: { identifier: 0, Y: 0 },
            recordTimer: null,
            recordLength: 0,

            //播放语音相关参数
            AUDIO: uni.createInnerAudioContext(),
            playMsgid: null,
            VoiceTimer: null,
            // 抽屉参数
            popupLayerClass: '',
            // more参数
            hideMore: true,
            //表情定义
            hideEmoji: true,
            emojiList: emoji,
            //红包相关参数
            windowsState: '',
            redenvelopeData: {
                rid: null, //红包ID
                from: null,
                face: null,
                blessing: null,
                money: null
            },
            loading: false,
            QiniuData: {
                mediaToken: '', //多媒体token
                imagesToken: '' //图片token
            },
            uploadPicUrl: '', //提交到后台图片地址
            fileList: [],
            goods: '',
            source: '',
            socketTask: null,
            teamUser: [
                {
                    id: this.$store.state.userInfo.id,
                    name: this.$store.state.userInfo.name
                }
            ],
            editUrl: '../notepad/zhihuiTeam/leagueMemberTwo',
            category: {
                title: '智汇团队',
                icon: '../../static/HM-chat/zhtd.png'
            },
            msg_Storage_key: '',
            showQrcode: false,
            isLeader: false,
            userId: '',
            unReadMsgNum: []
        };
    },
    //导航按钮
    onNavigationBarButtonTap(obj) {
        this.$mRouter.push({
            route: this.$mRoutesConfig.counterindex
        });
    },
    onReady() {
        //this.getTeam();
        uni.hideTabBar();
    },
    created() {
        // this.interval=setInterval(() => this.msgUnread(), 10000);
    },
    onLoad(option) {
        //语音自然播放结束
        this.AUDIO.onEnded(res => {
            this.playMsgid = null;
        });
        // #ifndef H5
        //录音开始事件
        this.RECORDER.onStart(e => {
            this.recordBegin(e);
        });
        //录音结束事件
        this.RECORDER.onStop(e => {
            this.recordEnd(e);
        });
        // #endif
        var that = this;
        this.getTeam(); //获取默认团队信息
        that.msgList = [];

        uni.$on('websocket-message-process', res => {
            const msgData = JSON.parse(res.data);

            if ('' + msgData === '{}' || !msgData?.type) {
                return;
            }

            // if (type == 'chat') {
            //     if (msgData != undefined) that.onlineMsgList(msgData);
            // }
            // if (type == 'offline_chat') {
            //     if (msgData != undefined && JSON.stringify(msgData.msg) != '{}' && msgData.msg != null) {
            //         uni.setStorageSync('offline_chat', msgData);
            //     }
            //     if (msgData != undefined) that.offlineMsgList(msgData);
            // }
            // this.$forceUpdate();

            if (msgData.type === 'chat' || msgData.type === 'offline_chat') {
                this.updateMsg();
            }
        });

        //请求离线消息
        //this.$store.commit('WEBSOCKET_SEND', JSON.stringify({ type: 'offline_chat'})); //发送当前聊天窗口信息
    },
    onShow() {
        if (uni.getStorageSync('unReadMsgNum' + this.$store.state.userInfo.id)) {
            this.unReadMsgNum = uni.getStorageSync('unReadMsgNum' + this.$store.state.userInfo.id);
        }
        if (uni.getStorageSync('syncCourse')) uni.removeStorageSync('syncCourse');
        const msgType = uni.getStorageSync('msgType');
        const tmpMsgId = uni.getStorageSync('tmpMsgId');
        if (msgType) {
            this.type = msgType;
            this.getTeamUsers();
            this.getMsgUserId(tmpMsgId);
            this.toUserId = tmpMsgId;
            this.isGroup = false;
            this.toType = 0;
            uni.removeStorageSync('tmpMsgId');
            uni.removeStorageSync('msgType');
        }
        if (JSON.stringify(this.$store.state.userInfo) == '{}') {
            uni.redirectTo({
                url: '../login/login'
            });
        } else {
            if (this.userinfo.id != this.$store.state.userInfo.id) {
                if (this.toUserId == this.$store.state.userInfo.id) this.toUserId = '';
                this.userinfo = this.$store.state.userInfo;
                this.initMsgList(); //初始获取聊天列表
            }
            this.getMyInquiry();
            this.getmyProject();
            if (uni.getStorageSync('mUid') != undefined) {
                if (uni.getStorageSync('mUid') != this.$store.state.userInfo.id) {
                    this.getUserJoinGroup(this.type); //获取左侧列表
                    this.getTeam(); //获取默认团队信息
                    uni.setStorageSync('mUid', this.$store.state.userInfo.id);
                }
            } else {
                uni.setStorageSync('mUid', this.$store.state.userInfo.id);
            }
            this.unReadMatchMsg();
            this.getmyAllAskCount();
            this.getmyFriends();
            this.getcheckLeader();
        }

        //获取离线消息
        // if (this.$store.state.is_open_socket) {
        //     this.$store.commit('WEBSOCKET_SEND', JSON.stringify({ type: 'offline_chat' }));
        // }

        // #ifdef APP-PLUS
        uni.hideTabBar();
        // #endif
    },
    mounted() {
        let token = uni.getStorageSync('token');
        this.initMsgList(); //初始获取聊天列表
        this.watchHeight(); //监听窗口高度
        // 检查链接情况
        this.connectSocketInit();
    },
    //导航按钮
    onNavigationBarButtonTap(obj) {
        this.selectCity();
    },
    watch: {
        contentHeight(val) {
            this.contentHeight = val;
        }
    },
    methods: {
        updateMsg() {
            let msgKey;

            // if (this.isGroup) {
            //     if (type === 999) {
            //         msgKey = this.type + '_';
            //     } else {
            //         msgKey = this.type + '_' + this.teamId;
            //     }
            // } else {
            //     msgKey = this.type + '_' + this.teamId + '_' + this.toUserId;
            // }

            if (this.isGroup) {
                msgKey = this.msgKey();
            } else {
                msgKey = this.msgKey(this.toUserId);
            }

            let msg = utils.getMessage(msgKey) || [];
            
            
            console.log(123125125125);
            console.log(msgKey);

            this.updateUnRead(msgKey);

            this.msgList = msg;

            this.$nextTick(() => {
                this.goToBottom(9999);
            });
        },
        updateUnRead(msgKey) {
            if (!this.userinfo.id) {
                return;
            }

            utils.handleUnReadMsg(msgKey, false);

            const unRead = utils.getUnReadMsg();

            this.unReadMsgNum = unRead;
        },
        async backGroup() {
            let data = await this.$apis.fetchGroupPerson({
                id: this.teamId,
                type: this.type
            });
            this.teamUser = data.data;
            this.getfetchRoomSetting(); //获取群设置
            this.getcheckLeader();
            this.hideTeamMember = false;
        },
        //获取嵌套团队成员
        async showTeamMember(item) {
            console.log('这是一个团队', item);
            let result = await this.$apis.fetchGroupPerson({
                id: item.groupId,
                type: item.groupType
            });
            this.teamUser = result.data;
            this.hideTeamMember = true;
        },
        report() {
            this.viewpointCurror = 1;
            this.showViewpoint = true;
        },
        /*搜索好友和团队*/
        async searchFriend(e) {
            let result = await this.$apis.fetchUserOrTeam({ code: e });
            this.friendList = result.data;
            console.log('searchFriend', e);
        },
        /*监听窗口高度*/
        watchHeight() {
            var that = this;
            uni.getSystemInfo({
                success: function(res) {
                    that.scrollHeight = res.windowHeight;
                }
            });
            let box = uni
                .createSelectorQuery()
                .in(that)
                .select('.input-box');
            var boxTop = 0;
            box.boundingClientRect(data => {
                that.boxTop = data.top;
            }).exec();
            let view = uni
                .createSelectorQuery()
                .in(that)
                .select('.moredown');
            view.boundingClientRect(data => {
                that.contentHeight = that.boxTop - data.top - 135;
                that.contentTop = data.top + 120;
            }).exec();

            let wdfx = uni
                .createSelectorQuery()
                .in(that)
                .select('.wdfx');
            wdfx.boundingClientRect(data => {
                that.marginRight = data.left - 20;
            }).exec();
            this.$forceUpdate();
        },
        leftClick() {
            //返回
            uni.switchTab({
                url: '../tabBar/index'
            });
        },
        /*扫码推广加群*/
        scanCode() {
            var _this = this;
            //扫一扫
            uni.scanCode({
                scanType: ['qrCode'],
                success: function(res) {
                    _this.getScanQrcode(res.result);
                }
            });
        },
        async getScanQrcode(content) {
            let result = await this.$apis.scanQrcode({ content: content });
            uni.showToast({
                title: result.message,
                icon: 'none'
            });
        },
        /*展示二维码*/
        async getQrcode() {
            this.showQrcode = true;
            let result = await this.$apis.genQrcode({
                id: this.teamId,
                type: this.type,
                name: this.category.title
            });
            this.qrcode = result.data.url;
        },
        /*下载二维码*/
        downLoadQrcode() {
            uni.downloadFile({
                url: this.$mConfig.baseUrl + this.qrcode,
                success: res => {
                    if (res.statusCode === 200) {
                        uni.saveImageToPhotosAlbum({
                            filePath: res.tempFilePath,
                            success: function() {
                                uni.showToast({
                                    title: '保存成功',
                                    icon: 'none'
                                });
                            },
                            fail: function() {
                                uni.showToast({
                                    title: '保存失败，请稍后重试',
                                    icon: 'none'
                                });
                            }
                        });
                    }
                }
            });
        },
        toHomePage(id) {
            uni.navigateTo({
                url: '../authorization/homepage?id=' + id
            });
        },
        changeFoldState() {
            this.toUserId = this.toUserId;
            this.openUsers = !this.openUsers;
            this.$refs.uReadMore.toggleReadMore();
            if (!this.openUsers) {
                this.userText = '收起';
            } else {
                this.userText = '更多';
            }
        },
        closeMore() {
            this.showMsg = true;
            this.openUsers = true;
            this.userText = '更多';
        },
        close(e) {},
        open(e) {},
        async getcheckLeader() {
            if (this.groupId) {
                let result = await this.$apis.checkLeader({ teamChatId: this.groupId });
                this.checkLeader = result.data;
            }
        },
        async getmyFriends() {
            if (this.groupId) {
                let result = await this.$apis.fetchUser({ teamChatId: this.groupId });
                this.myFriends = result.data;
            }
        },
        async getfetchRoomSetting() {
            let reqBody = {};
            console.log('groupId', this.groupId);
            if (this.groupId) {
                reqBody['teamChatId'] = this.groupId;
                console.log('isGroup', this.isGroup);
                if (!this.isGroup) {
                    let isUser = false;
                    for (var i in this.teamUser) {
                        if (this.teamUser[i].id == this.toUserId) {
                            isUser = true;
                        }
                    }
                    if (isUser) reqBody['userId'] = this.toUserId;
                }
                let result = await this.$apis.fetchRoomSetting(reqBody);
                if (result.data.code) this.groupCode = result.data.code;
                this.settings = result.data.setting != null ? result.data.setting : {};
                this.setUser = Object.assign(result.data.user, result.data.userSetting);
            }
        },
        async unReadMatchMsg() {
            let result = await this.$apis.unReadMatchMsg();
            this.unReadMsg = result.data;
        },
        async showViewpoints() {
            this.viewpointCurror = 0;
            this.showWdfq = false;
            if (this.project) {
                if (this.detailId !== '' && this.toUserId != '') {
                    let result = await this.$apis.myView({
                        projectId: this.detailId,
                        userId: this.toUserId
                    });
                    if (result.code == 200) {
                        this.viewpoint = result.data;
                        this.showViewpoint = true;
                    }
                } else {
                    uni.showModal({
                        title: '提示',
                        content: '请先选择项目或成员',
                        success: function(res) {}
                    });
                }
            } else {
                uni.showModal({
                    title: '提示',
                    content: '您还没有添加项目',
                    success: function(res) {}
                });
            }
        },
        showArbitrations() {
            this.showWdfq = false;
            if (this.project) {
                this.showArbitration = true;
            } else {
                uni.showModal({
                    title: '提示',
                    content: '您还没有添加项目',
                    success: function(res) {}
                });
            }
        },
        showPay() {
            this.showWdfq = false;
            if (this.project) {
                if (!this.toUserId || this.isGroup) {
                    uni.showModal({
                        title: '提示',
                        content: '请选择收款人',
                        success: function(res) {}
                    });
                } else {
                    this.openPay = true;
                }
            } else {
                uni.showModal({
                    title: '提示',
                    content: '您还没有添加项目',
                    success: function(res) {}
                });
            }
        },
        async getMyInquiry() {
            let result = await this.$apis.findProvinceCityDistrictByTree();
            this.myInquiry = result.data;
        },
        async getmyProject() {
            let result = await this.$apis.myProject();
            this.project = result.data;
            this.myProject = result.data;
        },
        /*事件提醒*/
        setInputCustom(title, content) {
            this.noticeTitle = title;
            this.noticeContent = content;
        },
        async handleAddTag() {
            if (this.noticeTitle === '' || this.noticeContent === '') {
                this.$refs.uToast.show({
                    title: '内容不能为空',
                    type: 'warning'
                });
                return;
            }
            let that = this,
                toType = this.isGroup ? 1 : 0,
                to = this.isGroup ? this.teamId : this.toUserId,
                content =
                    "<div style='width:128px;font-size:16px;padding-bottom:5px;text-align:center;'>" +
                    this.noticeTitle +
                    "</div><div style='width:128px;color:#666;font-size:14px;text-align:center;'>" +
                    this.noticeContent +
                    '</div>',
                type = 'notice';
            let model = {
                businessId: to,
                content: this.noticeContent,
                title: this.noticeTitle,
                type: this.type,
                toType: toType
            };
            let result = await this.$apis.addNotice(model);
            if (result.data.id) {
                that.sendMsg(content, type, result.data.id);
                this.popupActive = false;
            } else {
                uni.showToast({
                    title: '发送失败',
                    icon: 'none'
                });
            }
        },
        async noticeDetail(id) {
            let result = await this.$apis.readNotice({ id: id });
            if (result.code == 200) {
                let that = this,
                    toType = this.isGroup ? 1 : 0,
                    to = this.isGroup ? this.teamId : this.toUserId,
                    content =
                        "<div style='width:128px;font-size:16px;padding-bottom:5px;text-align:center;'>" +
                        result.data.title +
                        "</div><div style='width:128px;color:#666;font-size:14px;text-align:center;'>" +
                        result.data.content +
                        '</div>',
                    type = 'notice';
                if (this.isGroup) {
                    to = this.groupId;
                    toType = 1;
                }
                var sendName = this.userinfo.nickName ? this.userinfo.nickName : this.userinfo.name;
                var groupType = this.type + '_' + this.teamId;
                let sendMsg = {
                    type: 'chat',
                    msg: {
                        from: this.userinfo.id,
                        fromName: sendName,
                        to: to,
                        type: type,
                        id: id,
                        status: 1,
                        content: content,
                        groupType: groupType,
                        toType: toType //0单聊  1群聊
                        //"excludeIds":[1,2]
                    }
                };

                this.screenMsg(sendMsg); //加载到聊天窗口
                if (this.$store.state.is_open_socket) {
                    this.$store.commit('WEBSOCKET_SEND', JSON.stringify(sendMsg)); //发送当前聊天窗口信息
                }
            } else {
                uni.showToast({
                    title: result.message,
                    icon: 'none'
                });
            }
        },
        async setting(e) {
            console.log('设置返回', e);
            if (e.model == 'dismiss') {
                let { code } = await this.$apis.outOrDeleteGroup({
                    groupId: this.teamId,
                    groupType: this.type
                });
                if (code == 200) {
                    uni.showToast({
                        title: '解散/退出成功'
                    });
                    setTimeout(function() {
                        uni.navigateBack({
                            delta: 0
                        });
                    }, 2000);
                }
            } else {
                if (!this.isGroup && this.toUserId != '') {
                    e.model['targetUserId'] = this.toUserId;
                }
                let result = await this.$apis.saveRoomSetting(e.model);

                let data = await this.$apis.fetchGroupPerson({
                    id: this.teamId,
                    type: this.type
                });
                this.teamUser = data.data;
                this.getfetchRoomSetting(); //获取群设置
                this.getcheckLeader();
            }
        },
        async hbDetail(id) {
            let result = await this.$apis.receiveHandRedEnvelopes({ id: id });
            if (result.code == 200) {
                let that = this,
                    content =
                        "<div style='width:128px;font-size:16px;padding-bottom:5px;text-align:center;'>红包</div><div style='width:128px;color: rgba(255,255,255,0.7);font-size:14px;text-align:center;'>已领取红包</div>",
                    type = 'HB';
                if (id) {
                    that.sendMsg(content, type, id);
                } else {
                    uni.showToast({
                        title: '发送失败',
                        icon: 'none'
                    });
                }
            } else {
                uni.showToast({
                    title: result.message,
                    icon: 'none'
                });
            }
        },
        addMore() {
            uni.navigateTo({
                url: '../authorization/lookingfor'
            });
        },
        async agree(status = 0) {
            if (!this.argeeIds) {
                uni.showToast({
                    title: '请先选择申请人'
                });
            }
            let result = await this.$apis.processApply({
                ids: this.argeeIds,
                status: status,
                type: this.type
            });
            if ((result.code = 200)) {
                this.getmyAllAskCount();
                this.getTeamUsers(this.teamId);
            }
            this.show = false;
        },
        async handleClickInquiry(e) {
            console.log(e.model);
            if (e.model.projectName == '') {
                uni.showToast({
                    title: '请填写项目名称',
                    icon: 'none'
                });
                return;
            }
            e.model.expiredTime = new Date(e.model.expiredTime).getTime();
            let result = await this.$apis.addInquiry(e.model);
            if (result.code == 200) {
                uni.showToast({
                    title: '询价提交成功',
                    icon: 'none'
                });
                this.showInquiry = false;
                var msgTitle = '工程询价';
                console.log('type', e.model.type);
                if (e.model.type != 1) {
                    msgTitle = '采购询价';
                }
                var that = this,
                    to = this.toUserId,
                    toType = 0,
                    content =
                        "<div style='width:128px;font-size:16px;padding-bottom:5px;text-align:center;'>" +
                        msgTitle +
                        "</div><div style='width:128px;font-size:14px;color:#666;text-align:center;'>" +
                        e.model.projectName +
                        '</div>',
                    type = 'inquiry';
                if (result.data.id) {
                    that.sendMsg(content, type, result.data.id);
                } else {
                    uni.showToast({
                        title: '发送失败',
                        icon: 'none'
                    });
                }
            }
        },
        handleClickInquiryShow(e) {
            this.inquiryId = e;
            this.inquiryShow = true;
            this.inquiryInfo(e);
        },
        async inquiryInfo(e) {
            let { data } = await this.$apis.inquiryInfo({ id: e });
            this.inquiryItems = data;
        },
        async inquiryDetail() {
            this.inquiryShow = false;
            let reqBody = {
                projectInquiryId: this.inquiryId,
                userId: this.userinfo.id,
                userQuotedPrice: this.inquiryMoney
            };
            let result = await this.$apis.inquiryQuotedPrice(reqBody);
            if (result.code == 200) {
                let that = this,
                    toType = 0,
                    to = this.toUserId,
                    content =
                        "<div style='width:128px;font-size:16px;padding-bottom:5px;text-align:center;'>我的报价</div><div style='width:128px;color:#666;font-size:14px;text-align:center;'>" +
                        this.inquiryMoney +
                        '</div>',
                    type = 'inquiry';
                if (this.inquiryId) {
                    that.sendMsg(content, type, this.inquiryId);
                } else {
                    uni.showToast({
                        title: '发送失败',
                        icon: 'none'
                    });
                }
            } else {
                uni.showToast({
                    title: result.message,
                    icon: 'none'
                });
                return;
            }
        },
        async handleClickViewpoint(e) {
            var that = this;
            if (that.viewpointCurror < 1) {
                if (e.model.type === 0 && e.model.score == '') {
                    uni.showToast({
                        title: '请先评分',
                        icon: 'none'
                    });
                    return;
                }
                if (this.toUserId == '') {
                    uni.showToast({
                        title: '请先选择评分成员',
                        icon: 'none'
                    });
                    setTimeout(function() {
                        that.showViewpoint = false;
                    }, 1000);
                    return;
                }
            }
            e.model.businessId = this.detailId;
            e.model.toUserId = this.toUserId;
            let result = await this.$apis.addEvaluation(e.model);
            if (result.code == 200) {
                uni.showToast({
                    title: '提交成功',
                    icon: 'none'
                });
                if (that.viewpointCurror < 1) {
                    let data = await this.$apis.myView({
                        projectId: this.detailId,
                        userId: this.toUserId
                    });
                    this.viewpoint = data.data;
                }
                setTimeout(function() {
                    that.showViewpoint = false;
                }, 1000);
            }
        },
        showToast() {
            this.showWdfq = false;
            uni.showToast({
                title: '敬请期待',
                icon: 'none'
            });
        },
        async handleClickFriend(e) {
            // if (this.type == 1) {
            //     const currentType = parseInt(this.currentTeam.teamType);

            //     if ((e.userType != 10 && parseInt(this.currentTeam.teamType) !== e.userType) || (e.userType == 10 && e.teamType !== parseInt(this.currentTeam.teamType))) {
            //         uni.showToast({
            //             title: '被邀请成员身份类型不符',
            //             icon: 'none'
            //         });
            //         return;
            //     }
            // }

            const currentType = this.currentTeam;

            console.log(currentType);

            if (currentType.type !== 3) {
                if (e.teamType === 3) {
                    uni.showToast({
                        title: '被邀请成员身份类型不符',
                        icon: 'none'
                    });
                    return;
                }

                if (currentType.type === 1) {
                    if (e.teamType === 3 || e.userType === currentType.teamType) {
                        uni.showToast({
                            title: '被邀请成员身份类型不符',
                            icon: 'none'
                        });
                        return;
                    }
                }
            }

            let reqBody = {
                id: this.teamId, // group id
                userId: e.id, // 加入的用户id
                userType: e.userType, // 加入的用户类型 1：user,2：company,3:team
                type: this.type // group type
            };
            if (e.userType == 10) reqBody.teamType = this.type;
            let result = await this.$apis.joinGroup(reqBody);
            if (result.code == 200) {
                this.showFriends = false;
                this.getTeamUsers(this.detailId);
                uni.showToast({
                    title: '邀请成功'
                });
            }
        },
        async handleClickPay(e) {
            console.log('e', e);
            if (e.model.projectId == null) {
                uni.showToast({
                    title: '请先选择项目',
                    icon: 'none'
                });
                return;
            }
            if (e.model.dealAmount == null) {
                uni.showToast({
                    title: '请输入合同金额',
                    icon: 'none'
                });
                return;
            }
            if (e.model.payAmount == null) {
                uni.showToast({
                    title: '请输入支付金额',
                    icon: 'none'
                });
                return;
            }
            if (e.model.payProportion == null) {
                uni.showToast({
                    title: '请输入支付比例',
                    icon: 'none'
                });
                return;
            }
            if (e.model.frequency == null) {
                uni.showToast({
                    title: '请输入支付次数',
                    icon: 'none'
                });
                return;
            }
            // if(e.model.commission == null){
            // 	uni.showToast({
            // 		title:"请输入平台佣金",
            // 		icon:"none"
            // 	})
            // 	return;
            // }
            e.model.receiveId = this.toUserId;
            let result = await this.$apis.payment(e.model);
            if (result.code == 200) {
                uni.showToast({
                    title: '支付成功',
                    icon: 'none'
                });
                this.openPay = false;
            }
        },
        async handleClickArbitration(e) {
            if (e.model.projectId == undefined) {
                uni.showToast({
                    title: '请先选择项目',
                    icon: 'none'
                });
                return;
            }
            if (e.model.address == undefined) {
                uni.showToast({
                    title: '请输入项目地点',
                    icon: 'none'
                });
                return;
            }
            if (e.model.stage == undefined) {
                uni.showToast({
                    title: '请输入进展阶段',
                    icon: 'none'
                });
                return;
            }
            if (e.model.dispute == undefined) {
                uni.showToast({
                    title: '请选择争议诉求',
                    icon: 'none'
                });
                return;
            }
            if (e.model.disputeRemark == undefined) {
                uni.showToast({
                    title: '请输入争议说明',
                    icon: 'none'
                });
                return;
            }
            let result = await this.$apis.addArbitration(e.model);
            if (result.code == 200) {
                uni.showToast({
                    title: '仲裁提交成功',
                    icon: 'none'
                });
                this.showArbitration = false;
            }
        },
        regNumber(number) {
            if (!number) {
                this.$refs.uToast.show({
                    title: '内容不能为空',
                    type: 'default'
                });

                return false;
            }

            if (!/^[0-9]*$/.test(number)) {
                this.$refs.uToast.show({
                    title: '请输入整数',
                    type: 'default'
                });

                return false;
            }

            return true;
        },
        async handleClickSave(e) {
            console.log(e);
            const { cate, companyName, money, dy, num, ranges, remark } = e.model;

            if (!num || !ranges || !money || !companyName || !remark || !cate) {
                uni.showToast({
                    title: '请填写完整红包信息',
                    icon: 'none'
                });

                return;
            }

            if (ranges === '1' && !dy && !ly) {
                uni.showToast({
                    title: '请填写完整红包信息',
                    icon: 'none'
                });

                return;
            }

            //console.log("model:",e.model);
            // let result = await this.$apis.addHandRedEnvelopes(e.model);
            // if(result.code == 500){
            // 	uni.showToast({
            // 		title:result.message
            // 	})
            // }
            // this.showHB = false;
            // var remark =  "恭喜发财";
            // if(e.model.remark){
            // 	remark = "恭喜发财";
            // }
            // var that = this,to=this.toUserId,toType=0,content = "<div style='width:128px;font-size:16px;padding-bottom:5px;text-align:center;'>红包</div><div style='width:128px;color: rgba(255,255,255,0.7);font-size:14px;text-align:center;'>"+remark+"</div>",type="HB";
            // if(result.data.id){
            // 	that.sendMsg(content,type,result.data.id);
            // }else{
            // 	uni.showToast({
            // 		title:"发送失败",
            // 		icon:'none'
            // 	})
            // }
            console.log(e);

            let data = await this.$apis.currentAccountInfo();
            if (data.code !== 200) {
                return;
            }

            if (data.data.zhcoin < +money * +num) {
                this.$refs.uToast.show({
                    title: '余额不足',
                    type: 'default'
                });

                return;
            }

            this.$store.commit(
                'WEBSOCKET_SEND',
                JSON.stringify({
                    type: 'sendRedPacket',
                    fromUserId: this.$store.state.userInfo.id,
                    redPacketInfo: {
                        type: 1,
                        money,
                        count: num,
                        ruleType: ranges,
                        dy,
                        userName: companyName,
                        description: cate,
                        remark,
                        ly
                    }
                })
            );

            this.showHB = false;
        },
        confirmQrfq(e) {
            this.noticeType = e[0].value;
            if (e[0].value == '预付款申请') {
                this.noticeTitle = '预付款申请';
                this.noticeContent = '到支付预付款时间，请确认+支付完成，已确认';
            } else if (e[0].value == '付款申请') {
                this.noticeTitle = '付款申请';
                this.noticeContent = '到付款时间，请确认+支付完成，已确认';
            } else if (e[0].value == '退款申请') {
                this.noticeTitle = '退款申请';
                this.noticeContent = '已申请退款，请确认+申请退款，已确认';
            } else if (e[0].value == '终止合作') {
                this.noticeTitle = '终止合作';
                this.noticeContent = '请求终止合作，请确认+同意终止，已确认';
            }
            this.showWdfq = false;
            this.popupActive = true;
        },
        checkboxGroupChange(e) {
            this.argeeIds = e;
        },
        async getmyAllAskCount() {
            //console.log(this.type);
            let reqBody = { type: this.type };
            if (this.teamId != '') {
                reqBody.id = this.teamId;
                let result = await this.$apis.myAllAsk(reqBody);
                this.myAllAsk = result.data;
            }
        },
        async getmyAllAsk() {
            //console.log(this.type);
            let reqBody = { type: this.type };
            if (this.teamId != '') {
                reqBody.id = this.teamId;
                let result = await this.$apis.myAllAsk(reqBody);
                if (result.data.length > 0) {
                    this.showQr = true;
                    this.show = true;
                    this.myAllAsk = result.data;
                } else {
                    uni.showToast({
                        title: '您还没有收到申请反馈',
                        icon: 'none'
                    });
                    return;
                }
            } else {
                uni.showToast({
                    title: '请先选择团队或项目',
                    icon: 'none'
                });
                return;
            }
        },
        wdfk() {
            this.getmyAllAsk();
        },
        showChild(type) {
            this.child = this.child == type ? '' : type;
        },
        msgKey(id) {
            if (!this.userinfo) {
                return;
            }

            if (id) {
                if (this.type === 999) {
                    return 'gMsgList-' + this.userinfo.id + '-' + this.type + '_' + '_' + id;
                }
                return 'gMsgList-' + this.userinfo.id + '-' + this.type + '_' + this.teamId + '_' + id;
            }

            return 'gMsgList-' + this.userinfo.id + '-' + this.type + '_' + this.teamId;
        },
        getMsgUserId(id) {
            var that = this;
            //隐藏
            // if (this.hideTeamMember) return;
            if (!this.openUsers) {
                this.openUsers = !this.openUsers;
                this.$refs.uReadMore.toggleReadMore();
                if (!this.openUsers) {
                    this.userText = '收起';
                } else {
                    this.userText = '更多';
                }
            }

            let msgKey = this.msgKey(id);
            // console.log(msgKey);
            this.updateUnRead(msgKey);

            //清除未读数
            // if (this.unReadMsgNum.length > 0) {
            //     if (this.type == 999) {
            //         var groupType999 = '999_999';
            //         var isOne = false;
            //         var groupType = '999_' + id;
            //         console.log('删除', groupType);
            //         var index = this.unReadMsgNum.findIndex(item => {
            //             if (item == groupType) {
            //                 return true;
            //             }
            //         });
            //         this.$delete(this.unReadMsgNum, index);
            //         //删除临时聊天未读数
            //         for (var i in this.unReadMsgNum) {
            //             if (this.unReadMsgNum[i]?.indexOf('999_') === -1) {
            //                 isOne = true;
            //             }
            //         }
            //         if (isOne) {
            //             var index = this.unReadMsgNum.findIndex(item => {
            //                 if (item == groupType999) {
            //                     return true;
            //                 }
            //             });
            //             this.$delete(this.unReadMsgNum, index);
            //         }
            //     } else {
            //         var groupType = this.type + '_' + that.teamId + '_' + id;
            //         console.log('groupType', groupType);
            //         if (this.unReadMsgNum?.indexOf(groupType) !== -1) {
            //             var index = this.unReadMsgNum.findIndex(item => {
            //                 if (item == groupType) {
            //                     return true;
            //                 }
            //             });
            //             console.log('unReadMsgNum_index', index);
            //             this.$delete(this.unReadMsgNum, index);
            //         }
            //     }
            //     uni.setStorageSync('unReadMsgNum' + this.$store.state.userInfo.id, this.unReadMsgNum);
            // }

            if (id != that.$store.state.userInfo.id) {
                let toUserId = id;
                if (toUserId != that.toUserId) {
                    this.isGroup = false;
                    that.toUserId = toUserId;
                    this.msgList = [];
                    let sendNowMsg = {
                        type: 'chat',
                        msg: {
                            from: that.$store.state.userInfo.id,
                            to: toUserId,
                            toType: 0 //0单聊  1群聊
                        }
                    };
                    // that.$store.commit('SET_TOMSGGROUPID', ''); //单聊情况群组ID
                    // that.$store.commit('SET_TOMSGUSERID', toUserId); //存储聊天对象
                    that.$store.commit('WEBSOCKET_SEND', JSON.stringify(sendNowMsg)); //发送请求当前消息列表
                    //that.msgList = uni.getStorageSync('msgloalhost_'+ that.msg_Storage_key)  || [];   //加载列表
                } else {
                    if (this.type == 999) {
                        this.isGroup = false;
                        that.toUserId = toUserId;
                        this.msgList = [];
                        let sendNowMsg = {
                            type: 'chat',
                            msg: {
                                from: that.$store.state.userInfo.id,
                                to: toUserId,
                                toType: 0 //0单聊  1群聊
                            }
                        };
                        // that.$store.commit('SET_TOMSGGROUPID', ''); //单聊情况群组ID
                        // that.$store.commit('SET_TOMSGUSERID', toUserId); //存储聊天对象
                        that.$store.commit('WEBSOCKET_SEND', JSON.stringify(sendNowMsg)); //发送请求当前消息列表
                    } else {
                        this.isGroup = true;
                        that.toUserId = '';
                        if (this.teamId != '') this.$store.commit('SET_TOMSGDETAILID', this.teamId);
                        if (this.groupId != this.$store.state.toMsgGroupId) {
                            this.msgList = [];
                        }
                        if (this.groupId !== '') {
                            let sendNowMsg = {
                                type: 'chat',
                                msg: {
                                    from: this.userinfo.id,
                                    to: this.groupId,
                                    toType: 1 //0单聊  1群聊
                                }
                            };
                            this.$store.commit('WEBSOCKET_SEND', JSON.stringify(sendNowMsg)); //发送当前聊天窗口信息
                            this.$store.commit('SET_TOMSGGROUPID', this.$store.state.toMsgGroupId);
                        }
                    }
                }
                console.log('isGroup', this.isGroup);
                setTimeout(function() {
                    console.log('切换群组开始');
                    that.initMsgList();
                }, 200);

                if (this.type != 999) {
                    console.log('-=-=-=-=-=-=-=-=-加载个人设置=-=-=-===');
                    that.getfetchRoomSetting(); //加载个人设置
                }
            }
        },
        fbh() {
            this.$mRouter.push({
                route: this.$mRoutesConfig.releaseNumber
            });
        },
        async showDetial() {
            if (!this.checkLeader && this.toUserId) {
                let data = await this.$apis.summary({
                    id: this.teamId,
                    type: this.type,
                    userId: this.toUserId
                });
                if (data.code != 200) {
                    uni.showToast({
                        title: data.message,
                        icon: 'none'
                    });
                    return;
                }
            }
            var userId = '';
            var teamChatId = '';
            if (this.toUserId != '') userId = '&userId=' + this.toUserId;
            if (this.groupId != '') teamChatId = '&teamChatId=' + this.groupId;
            if (this.myTeams.length == 0) {
                uni.showToast({
                    title: '您还没有参与或添加' + this.category.title,
                    icon: 'none'
                });
                return;
            }

            var notepad = this.$mConstDataConfig.notepad;
            if (this.type < 999) {
                var type = parseInt(this.type) - 1;
                if (this.groupId) teamChatId = '&teamChatId=' + this.groupId;
                uni.navigateTo({
                    url: notepad[type].url + '?id=' + this.detailId + userId + teamChatId
                });
            } else {
                let id = this.teamId;
                if (!id) {
                    uni.showToast({
                        title: '请选择团队'
                    });
                    return;
                }
                uni.navigateTo({
                    url: notepad[0].url + '?id=' + id + userId + teamChatId
                });
            }
        },
        detail() {
            uni.navigateTo({
                url: '../notepad/communication/matchMessage'
            });
        },
        msg() {
            uni.navigateTo({
                url: '../notepad/communication/matchMessage'
            });
        },
        connectSocketInit() {
            var that = this;
            if (JSON.stringify(this.$store.state.is_open_socket) != '{}' && this.$store.state.is_open_socket) {
                that.screenMsg({
                    type: 'system',
                    msg: {
                        id: 0,
                        type: 'text',
                        content: { text: '欢迎使用智汇方舟系统' }
                    }
                });
            } else {
                console.log('is_open_socket', this.$store.state.is_open_socket);
            }
        },
        showEdit() {
            this.show = true;
            this.showQr = false;
        },
        isUnRead(groupType, type) {
            if (!this.userinfo.id) {
                return false;
            }

            const unRead = utils.getUnReadMsg();

            if (type) {
                let key;
                if (type !== 999 && type !== -1) {
                    key = 'gMsgList-' + this.userinfo.id + '-' + groupType + type;
                } else if (key === -1) {
                    key = 'gMsgList-' + this.userinfo.id + '-' + groupType.replace('_', '');
                } else {
                    key = 'gMsgList-' + this.userinfo.id + '-' + groupType.replace('_', '');
                }

                return Object.keys(unRead).some(item => {
                    const itemArr = item.split('-');
                    const last = itemArr.pop();

                    const last_first = last.split('_').shift();
                    itemArr.push(last_first);

                    return itemArr.join('-') === key && unRead[item];
                });
            }

            const key = 'gMsgList-' + this.userinfo.id + '-' + groupType;

            // console.log(key);

            return unRead[key];
        },
        showLeft(type, title, icon) {
            var _this = this;
            if (type > 0) {
                _this.tmpType = type;
                this.category = {
                    icon: icon,
                    title: title
                };
            } else {
                if (this.type) type = this.type;
            }
            //if(type == 999) return;
            _this.$store.commit('SET_MSGTYPE', type); //存储聊天对象
            ////console.log(type)
            _this.show = false;
            if (type != 999) {
                _this.showL = true;
                this.getUserJoinGroup(type); //获取左侧列表
            }

            if (type > 3) {
                this.leftLength = '50%';
            } else {
                this.leftLength = '27%';
            }
        },
        async getUserJoinGroup(type) {
            let result = await this.$apis.userJoinGroup({ type: type });

            console.log(6666666);
            console.log(JSON.stringify(result));

            this.myTeams = result.data;

            // if(result.data != undefined){
            // 	if(result.data[0] != undefined){
            // 		this.teamId = result.data[0].id;
            // 		this.getfetchGroupPerson(result.data[0].id);
            // 	}
            // }
        },
        async getTeam() {
            let result = await this.$apis.findTeamAll();
            if (result.data) {
                this.myTeams = result.data;

                if (result.data.length > 0) {
                    this.$store.commit('SET_TOMSGGROUPID', result.data[0].teamChatId);
                }

                if (result.data.length > 0) {
                    this.teamName = this.type == 999 ? '临时交流' : result.data[0].name;
                    this.getTeamUsers(result.data[0].id);
                    if (result.data[0].id > 0) {
                        this.teamId = result.data[0].id;
                        console.log(this.teamId);
                    }
                    this.groupId = result.data[0].teamChatId;
                    // this.groupId = result.data[0].type + '_' + result.data[0].id;

                    this.detailId = result.data[0].id;
                    this.getfetchRoomSetting(this.groupId);
                    this.getmyFriends();
                    this.getcheckLeader();
                }
            }
        },
        async getfetchGroupPerson(id) {
            let result = await this.$apis.fetchGroupPerson({
                id: id,
                type: this.type
            });
            this.teamUser = result.data;
            console.log('getfetchGroupPerson', this.teamUser);
        },
        getTeamUser(item) {
            var that = this;
            that.currentTeam = item; //当前团队
            that.type = that.tmpType;
            that.toUserId = ''; //初始化
            that.isGroup = true;
            ++that.settingKey;
            that.detailId = item.id;
            that.groupId = item.teamChatId;
            that.showL = false;
            if (item.id > 0) that.teamId = item.id;
            this.teamName = this.type == 999 ? '临时交流' : item.name;

            // this.updateUnRead(this.msgKey());

            //清除未读数
            // if (this.unReadMsgNum.length > 0) {
            //     var groupType = this.type + '_' + that.teamId;
            //     if (this.unReadMsgNum.indexOf(groupType) != -1) {
            //         var index = this.unReadMsgNum.findIndex(item => {
            //             if (item == groupType) {
            //                 return true;
            //             }
            //         });
            //         this.$delete(this.unReadMsgNum, index);
            //     }
            //     uni.setStorageSync('unReadMsgNum' + this.$store.state.userInfo.id, this.unReadMsgNum);
            // }

            this.$store.commit('SET_TOMSGDETAILID', item.id);

            // this.groupId = item.type + '_' + item.id;

            if (that.groupId != this.$store.state.toMsgGroupId) {
                that.msgList = [];
            }

            if (that.groupId) {
                let sendNowMsg = {
                    type: 'chat',
                    msg: {
                        from: that.userinfo.id,
                        to: that.groupId,
                        toType: 1 //0单聊  1群聊
                    }
                };
                this.$store.commit('WEBSOCKET_SEND', JSON.stringify(sendNowMsg)); //发送当前聊天窗口信息
                this.$store.commit('SET_TOMSGGROUPID', that.groupId);
            }
            that.getTeamUsers(item.id);
            that.initMsgList();
            that.getmyAllAskCount(); //获取申请请求
            that.getfetchRoomSetting(); //获取群设置
            that.getmyFriends(); //获取好友列表
            that.getcheckLeader(); //判断是否团长
        },
        /*临时聊天*/
        tempChat() {
            this.type = 999;
            this.show = false;
            this.msgList = [];
            this.teamName = '临时交流';
            this.getTeamUsers();
        },
        async getTeamUsers(id) {
            let result = [];
            result = await this.$apis.fetchGroupPerson({ id: id, type: this.type });
            this.teamUser = result.data;
            if (result.data && result.data.length > 0) {
                if (this.type != 999) this.isGroup = true;
                console.log('isGroup', this.isGroup);
            }
        },
        // 当前日期
        nowFormatDate() {
            var date = new Date();
            var seperator1 = '-';
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            if (month >= 1 && month <= 9) {
                month = '0' + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = '0' + strDate;
            }
            var currentdate = year + seperator1 + month + seperator1 + strDate;
            console.log('currentdate', currentdate);
            return currentdate;
        },
        // 接受消息(筛选处理)
        async screenMsg(msg) {
            //console.log('msg',msg)
            if (msg != undefined) {
                //从长连接处转发给这个方法，进行筛选处理
                if (msg.type == 'system') {
                    // 系统消息
                    switch (msg.msg.type) {
                        case 'text':
                            this.addSystemTextMsg(msg);
                            //////console.log('加载内容');
                            break;
                    }
                } else if (msg.type == 'goods') {
                    // 商品消息
                    switch (msg.msg.type) {
                        case 'text':
                            //this.addSystemTextMsg(msg);
                            this.addTextMsg(msg);
                            break;
                    }
                } else if (msg.type == 'chat') {
                    //msg.msg.time = msg.msg.time.substring(11);
                    // 用户消息
                    switch (msg.msg.type) {
                        case 'text':
                            this.addTextMsg(msg);
                            break;
                        case 'notice':
                            this.addTextMsg(msg);
                            break;
                        case 'HB':
                            this.addTextMsg(msg);
                            break;
                        case 'voice':
                            this.addVoiceMsg(msg);
                            break;
                        case 'img':
                            this.addImgMsg(msg);
                            break;
                        case 'goods':
                            //this.addSystemTextMsg(msg);
                            let goodsData = await this.$apis.goodsinfo({
                                id: msg.msg.content.text
                            });
                            if (goodsData.status == 1) {
                                this.product = goodsData.result.goods;
                            }
                            this.addTextMsg(msg);
                            break;
                    }
                    ////////console.log('用户消息');
                    //非自己的消息震动
                    if (msg.msg.to != this.myuid) {
                        ////////console.log('振动');
                        uni.vibrateLong();
                    }
                }
                var that = this;
                this.$nextTick(function() {
                    // 滚动到底
                    that.goToBottom(99999);
                    if (msg.msg != undefined) {
                        this.scrollToView = 'msg' + msg.msg.chatId;
                    }
                });
            }
        },

        /*
			初始消息加载
		*/
        async initMsgList() {
            // var that = this,
            //     myuid = '',
            //     receiveId = '',
            //     roomId = '',
            //     teamId = '',
            //     type = '',
            //     list = [],
            //     msgloalhost = { dataList: [] };
            // that.msgList = [];
            // //获取当前会话标识
            // myuid = this.$store.state.userInfo.id; //当前登录人
            // receiveId = that.isGroup ? that.groupId : that.toUserId; //消息对象
            // if (this.teamId == '') {
            //     let result = await this.$apis.userJoinGroup({ type: 1 });
            //     this.myTeams = result.data;
            //     if (result.data != undefined && result.data.length > 0) {
            //         teamId = result.data[0].id;
            //         receiveId = 'team_' + result.data[0].id;
            //     }
            // }
            // teamId = this.type == 999 ? 999 : this.teamId; //当前群组
            // type = this.type ? this.type : this.$store.state.msgtype; //当前群聊类型

            // if (myuid != '' && receiveId != '') {
            //     if (that.isGroup) {
            //         roomId = 'group_' + receiveId + '_' + this.userinfo.id; //群聊
            //     } else {
            //         roomId = myuid < receiveId ? myuid + '_' + receiveId : receiveId + '_' + myuid; //私聊
            //     }
            // }

            // if (roomId != '') {
            //     var msg_Storage_key = type + '_' + teamId + '_' + roomId;
            //     that.msg_Storage_key = msg_Storage_key;
            //     if (uni.getStorageSync('msgloalhost_' + msg_Storage_key) != '') msgloalhost = uni.getStorageSync('msgloalhost_' + msg_Storage_key);

            //     that.msgImgList = [];
            //     if (JSON.stringify(msgloalhost.dataList) != '{}') {
            //         list = msgloalhost.dataList;

            //         if (list.length > 0) {
            //             //获取消息中的图片,并处理显示尺寸
            //             for (let i = 0; i < list.length; i++) {
            //                 list[i].msg.time = this.$mUtils.formatTimeMD(list[i].msg.sendTime);
            //                 if (list[i].type == 'chat' && list[i].msg.type == 'img') {
            //                     list[i].msg.content = that.setPicSize(list[i].msg.content);
            //                     that.msgImgList.push(list[i].msg.content.url);
            //                 }
            //             }
            //             that.msgList = list;

            //             setTimeout(() => {
            //                 that.$nextTick(function() {
            //                     //进入页面滚动到底部
            //                     that.goToBottom(99999);
            //                     that.$nextTick(function() {
            //                         that.scrollAnimation = true;
            //                     });
            //                 });
            //             }, 150);
            //         }
            //     }
            // }
            // that.isSpinnerhide = true;
            // that.isSpinner = false;

            this.updateMsg();
        },
        /*
			在线消息加载
		*/
        // onlineMsgList(msgData) {
        //     var that = this;
        //     //获取当前会话标识
        //     if (msgData != undefined && JSON.stringify(msgData.msg) != '{}' && msgData.msg != null) {
        //         if (this.unReadMsgNum.indexOf(msgData.msg.groupType) == -1) this.unReadMsgNum.push(msgData.msg.groupType);
        //         var numReg = /^[0-9]*$/;
        //         var numRe = new RegExp(numReg);
        //         if (numRe.test(msgData.msg.to)) {
        //             var gtype = msgData.msg.groupType + '_' + msgData.msg.from;
        //             if (this.unReadMsgNum.indexOf(gtype) === -1) this.unReadMsgNum.push(gtype);
        //         }
        //         uni.setStorageSync('unReadMsgNum' + this.$store.state.userInfo.id, this.unReadMsgNum);
        //         that.getMsgloalhost(msgData);
        //     }
        // },
        /*
			离线消息处理
		*/
        // offlineMsgList(msgData) {
        //     var that = this;
        //     //获取当前会话标识
        //     if (msgData != undefined && JSON.stringify(msgData.msg) != '{}' && msgData.msg != null) {
        //         if (msgData.msg.length > 0) {
        //             for (var i in msgData.msg) {
        //                 if (this.unReadMsgNum.indexOf(msgData.msg[i].groupType) == -1) this.unReadMsgNum.push(msgData.msg[i].groupType);
        //                 var numReg = /^[0-9]*$/;
        //                 var numRe = new RegExp(numReg);
        //                 if (numRe.test(msgData.msg[i].to)) {
        //                     var gtype = msgData.msg[i].groupType + '_' + msgData.msg[i].from;
        //                     if (this.unReadMsgNum.indexOf(gtype) === -1) this.unReadMsgNum.push(gtype);
        //                 }
        //                 uni.setStorageSync('unReadMsgNum' + this.$store.state.userInfo.id, this.unReadMsgNum);

        //                 var msgDataMsg = {
        //                     type: 'chat',
        //                     msg: msgData.msg[i]
        //                 };
        //                 that.getMsgloalhost(msgDataMsg);
        //             }
        //         }
        //         // if(msgData.msg.length == 1){
        //         // 	var msgDataMsg = {
        //         // 		type:"chat",
        //         // 		msg:msgData.msg
        //         // 	};
        //         // 	that.getMsgloalhost(msgData.msg.from,msgData.msg.to,msgDataMsg,msgData.msg.groupType);
        //         // }
        //     }
        // },
        /*
			发送消息处理
		*/
        sendMsgloalhost(msgData) {
            var that = this,
                //     roomId = '',
                //     list = [],
                //     msg_Storage_key = '',
                //     msgloalhost = { dataList: [] };
                // if (that.isGroup) {
                //     roomId = 'group_' + receiveId + '_' + myuid;
                // } else {
                //     if (myuid != '' && receiveId != '') {
                //         if (myuid < receiveId) {
                //             roomId = myuid + '_' + receiveId;
                //         } else {
                //             roomId = receiveId + '_' + myuid;
                //         }
                //     }
                // }

                // if (roomId != '') {
                //     let arrgroupType = groupType.split('_');
                //     let type = arrgroupType[0];
                //     let teamId = arrgroupType[1];
                //     if (teamId == '' && receiveId != '' && JSON.stringify(receiveId).indexOf('team') != -1) {
                //         let tids = receiveId.split('_');
                //         teamId = tids[1];
                //     }

                //     //生成key
                //     msg_Storage_key = type + '_' + teamId + '_' + roomId;
                //     that.msg_Storage_key = msg_Storage_key;
                //     if (uni.getStorageSync('msgloalhost_' + msg_Storage_key) != '') msgloalhost = uni.getStorageSync('msgloalhost_' + msg_Storage_key);
                //     if (msgData != undefined && JSON.stringify(msgData) != '{}') {
                //         msgData.msg.sendTime = this.$mUtils.getDateTime();
                //         //聊天存本地
                //         if (msgloalhost.dataList.length > 0) {
                //             var len = msgloalhost.dataList.length >= 1 ? msgloalhost.dataList.length - 1 : msgloalhost.dataList.length;
                //             if (msgloalhost.dataList[len] != undefined && msgData.msg.chatId > msgloalhost.dataList[len].msg.chatId) msgloalhost.dataList.push(msgData);
                //         } else {
                //             msgloalhost.dataList.push(msgData);
                //         }
                //         uni.setStorageSync('msgloalhost_' + msg_Storage_key, msgloalhost || {});

                //推送给聊天窗口
                list = msgData;
            list.msg.time = this.$mUtils.formatTimeMD(list.msg.sendTime);
            if (list.type == 'chat' && list.msg.type == 'img') {
                list.msg.content = that.setPicSize(list.msg.content);
                that.msgImgList.push(list.msg.content.url);
            }
            // that.msgList.push(list);

            utils.handleMessage(list);
            this.updateMsg();

            //         //聊天窗口自动滚动到底部
            //         setTimeout(() => {
            //             that.$nextTick(function() {
            //                 //进入页面滚动到底部
            //                 that.goToBottom(99999);
            //                 that.$nextTick(function() {
            //                     that.scrollAnimation = true;
            //                 });
            //             });
            //         }, 150);
            //         that.isSpinnerhide = true;
            //         that.isSpinner = false;
            //     }
            // }
        },
        /*接收socket数据*/
        getMsgloalhost(msgData) {
            var that = this;
            //     roomId = '',
            //     list = [],
            //     teamId = '',
            // msgloalhost = { dataList: [] };
            // if (receiveId && JSON.stringify(receiveId).indexOf('_') != -1) {
            //     roomId = 'group_' + receiveId + '_' + this.userinfo.id;
            // } else {
            //     if (myuid != '' && receiveId != '') {
            //         if (myuid < receiveId) {
            //             roomId = myuid + '_' + receiveId;
            //         } else {
            //             roomId = receiveId + '_' + myuid;
            //         }
            //     }
            // }

            // if (roomId != '' && groupType != undefined) {
            //     let arrgroupType = groupType.split('_');
            //     let type = arrgroupType[0];
            //     if (receiveId != '' && JSON.stringify(receiveId).indexOf('_') != -1) {
            //         let tids = receiveId.split('_');
            //         teamId = tids[1];
            //     }
            //     if (receiveId != '' && JSON.stringify(receiveId).indexOf('_') == -1) {
            //         teamId = arrgroupType[1];
            //     }

            //     var msg_Storage_key = type + '_' + teamId + '_' + roomId;
            //     that.msg_Storage_key = msg_Storage_key;

            // if (uni.getStorageSync('msgloalhost_' + msg_Storage_key) != '') msgloalhost = uni.getStorageSync('msgloalhost_' + msg_Storage_key);

            // if (msgData != undefined && JSON.stringify(msgData) != '{}') {
            //     //聊天存本地
            //     if (msgloalhost.dataList.length > 0) {
            //         var len = msgloalhost.dataList.length >= 1 ? msgloalhost.dataList.length - 1 : msgloalhost.dataList.length;
            //         if (msgloalhost.dataList[len] != undefined && msgData.msg.chatId > msgloalhost.dataList[len].msg.chatId) msgloalhost.dataList.push(msgData);
            //     } else {
            //         msgloalhost.dataList.push(msgData);
            //     }
            //     uni.setStorageSync('msgloalhost_' + msg_Storage_key, msgloalhost || {});
            // }

            // var nowMyuid = this.$store.state.userInfo.id,
            //     nowReceiveId = this.toUserId,
            //     nowRoomId = '';
            // if (nowMyuid < nowReceiveId) {
            //     nowRoomId = nowMyuid + '_' + nowReceiveId;
            // } else {
            //     nowRoomId = nowReceiveId + '_' + nowMyuid;
            // }

            // var now_teamId = this.type == 999 ? 999 : this.teamId; //当前群组
            // var now_key = '';
            // if (that.isGroup) {
            //     now_key = now_key = this.type + '_' + now_teamId + '_' + 'group_' + that.groupId + '_' + nowMyuid;
            // } else {
            //     now_key = this.type + '_' + now_teamId + '_' + nowRoomId;
            // }
            // console.log('now_key', now_key);
            // if (now_key == msg_Storage_key) {
            //推送给聊天窗口
            if (msgData.msg.chatId > msgloalhost.dataList[len].msg.chatId) {
                list = msgData;
                list.msg.time = this.$mUtils.formatTimeMD(list.msg.sendTime);
                if (list.type == 'chat' && list.msg.type == 'img') {
                    list.msg.content = that.setPicSize(list.msg.content);
                    that.msgImgList.push(list.msg.content.url);
                }
                // that.msgList.push(list);
                utils.handleMessage(list);
                this.updateMsg();
            }

            //聊天窗口自动滚动到底部
            // setTimeout(() => {
            //     that.$nextTick(function() {
            //         //进入页面滚动到底部
            //         that.goToBottom(99999);
            //         that.$nextTick(function() {
            //             that.scrollAnimation = true;
            //         });
            //     });
            // }, 150);
            this.isSpinnerhide = true;
            this.isSpinner = false;
        },

        //处理图片尺寸，如果不处理宽高，新进入页面加载图片时候会闪
        setPicSize(content) {
            // 让图片最长边等于设置的最大长度，短边等比例缩小，图片控件真实改变，区别于aspectFit方式。
            let maxW = uni.upx2px(350); //350是定义消息图片最大宽度
            let maxH = uni.upx2px(350); //350是定义消息图片最大高度
            if (content.w > maxW || content.h > maxH) {
                let scale = content.w / content.h;
                content.w = scale > 1 ? maxW : maxH * scale;
                content.h = scale > 1 ? maxW / scale : maxH;
            }
            return content;
        },

        //更多功能(点击+弹出)
        showMore() {
            this.isVoice = false;
            this.hideEmoji = true;
            if (this.hideMore) {
                this.hideMore = false;
                this.openDrawer();
            } else {
                this.hideDrawer();
            }
        },
        // 打开抽屉
        openDrawer() {
            this.popupLayerClass = 'showLayer';
        },
        // 隐藏抽屉
        hideDrawer() {
            this.popupLayerClass = '';
            setTimeout(() => {
                this.hideMore = true;
                this.hideEmoji = true;
            }, 150);
        },
        // 选择图片发送
        chooseImage() {
            this.getImage('album');
        },
        //拍照发送
        camera() {
            this.getImage('camera');
        },

        //选照片 or 拍照
        getImage(type) {
            this.hideDrawer();
            uni.chooseImage({
                sourceType: [type],
                sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
                success: res => {
                    for (let i = 0; i < res.tempFilePaths.length; i++) {
                        uni.getImageInfo({
                            src: res.tempFilePaths[i],
                            success: image => {
                                this.uploadToQiniu(res.tempFilePaths[i], image.width, image.height, 'pic');
                            }
                        });
                    }
                }
            });
        },
        uploadToQiniu(imgPath, width, height, type) {
            //console.log("imgPath:",imgPath);
            var that = this;
            uni.uploadFile({
                url: this.$apis.uploadFile, //仅为示例，非真实的接口地址
                filePath: imgPath,
                name: 'file',
                success: uploadFileRes => {
                    let imgData = JSON.parse(uploadFileRes.data);
                    let imgUrl = this.$mConfig.baseUrl + imgData.message;
                    if (type == 'pic') {
                        //console.log("imgUrl:",imgUrl);
                        let msg = { url: imgUrl, w: width, h: height };
                        that.sendMsg(msg, 'img');
                    } else if (type == 'media') {
                        let msg = {
                            length: 0,
                            url: imgUrl
                        };
                        let min = parseInt(width / 60);
                        let sec = width % 60;
                        min = min < 10 ? '0' + min : min;
                        sec = sec < 10 ? '0' + sec : sec;
                        msg.length = min + ':' + sec;
                        that.sendMsg(msg, 'voice');
                    }
                }
            });
        },
        // 选择表情
        chooseEmoji() {
            this.hideMore = true;
            if (this.hideEmoji) {
                this.hideEmoji = false;
                this.openDrawer();
            } else {
                this.hideDrawer();
            }
        },
        //添加表情
        addEmoji(em) {
            this.textMsg += em.alt;
        },

        //获取焦点，如果不是选表情ing,则关闭抽屉
        textareaFocus() {
            if (this.popupLayerClass == 'showLayer' && this.hideMore == false) {
                this.hideDrawer();
            }
        },
        // 发送文字消息
        sendText(type = 'text') {
            uni.hideKeyboard();
            if (this.type != 999 && this.groupId == '' && this.toUserId == '') {
                uni.showToast({
                    title: '请先选择聊天对象！',
                    icon: 'none'
                });
                return;
            }
            let lock = false;
            for (var i in this.teamUser) {
                if (this.$store.state.userInfo.id == this.teamUser[i].id) {
                    if (this.teamUser[i].lockFlag || this.teamUser[i].shieldFlag) lock = true;
                }
            }
            if (lock) {
                uni.showToast({
                    icon: 'none',
                    title: '您已被经禁言'
                });

                this.screenMsg({
                    type: 'system',
                    msg: { id: 0, type: 'text', content: { text: '您已被经禁言' } }
                });
                return;
            }

            this.hideDrawer(); //隐藏抽屉

            if (!this.textMsg) {
                return;
            }
            let content = this.replaceEmoji(this.textMsg);
            //console.log("content:",content)
            //let type = 'text';
            this.sendMsg(content, 'text');
            this.textMsg = ''; //清空输入框

            // 滚动到底部
            var that = this;
            this.$nextTick(function() {
                //进入页面滚动到底部
                that.goToBottom(99999);
                that.$nextTick(function() {
                    that.scrollAnimation = true;
                });
            });
            this.isSpinnerhide = true;
            //this.isSpinner = false;
        },
        // 容器滚动到底部
        goToBottom(scrollTop) {
            this.scrollTop = scrollTop + Math.random() * 10;
        },
        //替换表情符号为图片
        replaceEmoji(str) {
            let replacedStr = str.replace(/\[([^(\]|\[)]*)\]/g, (item, index) => {
                //////console.log('item: ' + item);
                for (let i = 0; i < this.emojiList.length; i++) {
                    let row = this.emojiList[i];
                    for (let j = 0; j < row.length; j++) {
                        let EM = row[j];
                        if (EM.alt == item) {
                            //在线表情路径，图文混排必须使用网络路径，请上传一份表情到你的服务器后再替换此路径
                            //比如你上传服务器后，你的100.gif路径为https://www.xxx.com/emoji/100.gif 则替换onlinePath填写为https://www.xxx.com/emoji/
                            let onlinePath = this.$mConfig.baseUrl + '/face/emoji/';
                            //let imgstr = '<img src="' + onlinePath + this.onlineEmoji[EM.url] + '">';
                            let imgstr = '<img src="' + onlinePath + EM.url + '">';
                            //////console.log('imgstr: ' + imgstr);
                            return imgstr;
                        }
                    }
                }
            });
            return '<div style="display: flex;align-items: center;word-wrap:break-word;flex-wrap: wrap;">' + replacedStr + '</div>';
            //return replacedStr;
        },

        // 添加文字消息到列表
        addTextMsg(msg) {
            if (!Array.isArray(this.msgList)) {
                this.msgList = [];
            }

            this.msgList.push(msg);
        },
        // 添加语音消息到列表
        addVoiceMsg(msg) {
            if (!Array.isArray(this.msgList)) {
                this.msgList = [];
            }

            this.msgList.push(msg);
        },
        // 添加图片消息到列表
        addImgMsg(msg) {
            msg.msg.content = this.setPicSize(msg.msg.content);
            // if (this.msgImgList != undefined) this.msgImgList.push(msg.msg.content.url);
            if (this.msgList != undefined) {
                // this.msgList.push(msg);
                utils.handleMessage(msg);
            }
        },
        addRedEnvelopeMsg(msg) {
            if (this.msgList != undefined) this.msgList.push(msg);
        },
        // 添加系统文字消息到列表
        addSystemTextMsg(msg) {
            if (!Array.isArray(this.msgList)) {
                this.msgList = [];
            }

            this.msgList.push(msg);
        },
        sendSystemMsg(content, type) {
            let lastid = this.msgList[this.msgList.length - 1].msg.chatId != undefined ? this.msgList[this.msgList.length - 1].msg.chatId : '';
            lastid++;
            let row = {
                type: 'system',
                msg: { id: lastid, type: type, content: content }
            };
            this.screenMsg(row);
        },
        //领取详情
        toDetails(rid) {
            uni.navigateTo({
                url: 'HM-details/HM-details?rid=' + rid
            });
        },
        // 预览图片
        showPic(msg) {
            uni.previewImage({
                indicator: 'none',
                current: msg.content.url,
                urls: this.msgImgList
            });
        },
        // 播放语音
        playVoice(msg) {
            this.playMsgid = msg.chatId;
            this.AUDIO.src = msg.content.url;
            this.$nextTick(function() {
                this.AUDIO.play();
            });
        },
        // 录音开始
        voiceBegin(e) {
            if (e.touches.length > 1) {
                return;
            }
            this.initPoint.Y = e.touches[0].clientY;
            this.initPoint.identifier = e.touches[0].identifier;
            this.RECORDER.start({ format: 'mp3' }); //录音开始,
        },
        //录音开始UI效果
        recordBegin(e) {
            this.recording = true;
            this.voiceTis = '松开 结束';
            this.recordLength = 0;
            this.recordTimer = setInterval(() => {
                this.recordLength++;
            }, 1000);
        },
        // 录音被打断
        voiceCancel() {
            this.recording = false;
            this.voiceTis = '按住 说话';
            this.recordTis = '手指上滑 取消发送';
            this.willStop = true; //不发送录音
            this.RECORDER.stop(); //录音结束
        },
        // 录音中(判断是否触发上滑取消发送)
        voiceIng(e) {
            if (!this.recording) {
                return;
            }
            let touche = e.touches[0];
            //上滑一个导航栏的高度触发上滑取消发送
            if (this.initPoint.Y - touche.clientY >= uni.upx2px(100)) {
                this.willStop = true;
                this.recordTis = '松开手指 取消发送';
            } else {
                this.willStop = false;
                this.recordTis = '手指上滑 取消发送';
            }
        },
        // 结束录音
        voiceEnd(e) {
            if (!this.recording) {
                return;
            }
            this.recording = false;
            this.voiceTis = '按住 说话';
            this.recordTis = '手指上滑 取消发送';
            this.RECORDER.stop(); //录音结束
        },
        //录音结束(回调文件)
        recordEnd(e) {
            clearInterval(this.recordTimer);
            if (!this.willStop) {
                //////console.log('e: ' + JSON.stringify(e));

                this.uploadToQiniu(e.tempFilePath, this.recordLength, 0, 'media');
            } else {
                //////console.log('取消发送录音');
            }
            this.willStop = false;
        },
        // 切换语音/文字输入
        switchVoice() {
            this.hideDrawer();
            this.isVoice = this.isVoice ? false : true;
        },
        discard() {
            return;
        },
        // 发送消息
        sendMsg(content, type, id = null) {
            var that = this;
            this.userinfo = this.$store.state.userInfo;
            let token = uni.getStorageSync('token');
            var groupType = this.type + '_' + this.teamId;
            if (token) {
                this.$store.commit('SET_TOMSGUSERID', that.toUserId); //被收消息的人
                var sendName = this.userinfo.nickName ? this.userinfo.nickName : this.userinfo.name;

                if (this.type == 999 && that.toUserId == '') {
                    uni.showToast({
                        title: '请先选择聊天对象',
                        icon: 'none'
                    });
                    return;
                }
                var date = Date.now();
                let sendMsg = {
                    type: 'chat',
                    msg: {
                        chatId: Math.floor(date * 1 + 1),
                        content: content,
                        from: this.userinfo.id,
                        fromName: sendName,
                        to: that.toUserId,
                        id: id,
                        type: type,
                        //sendTime:this.$mUtils.getDateTime(),
                        groupType: groupType,
                        toType: 0 //0单聊  1群聊
                        //"excludeIds":[1,2]
                    }
                };

                if (this.isGroup) {
                    sendMsg = {
                        type: 'chat',
                        msg: {
                            chatId: Math.floor(date * 1 + 1),
                            content: content,
                            from: this.userinfo.id,
                            fromName: sendName,
                            groupType: groupType,
                            //sendTime:this.$mUtils.getDateTime(),
                            to: this.groupId,
                            id: id,
                            toType: 1, //0单聊  1群聊
                            type: type
                            //"excludeIds":[1,2]
                        }
                    };
                }
                this.$store.commit('WEBSOCKET_SEND', JSON.stringify(sendMsg)); //发送当前聊天窗口信息

                that.sendMsgloalhost(sendMsg);
            }
        },
        showuToast() {
            uni.navigateTo({
                url: '../user/collection/index'
            });
        },
        inviteFriends() {
            this.showFriends = true;
            this.friendList = [];
        }
    }
};
</script>
<style lang="scss">
.bottom-box {
    height: 250rpx;
}
@import '@../../static/HM-chat/css/style.scss';
.m-menu {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 50rpx;
    .item {
        width: 90%;
        margin-left: 33rpx;
        padding: 25rpx 0;
        display: flex;
        align-items: center;
        position: relative;
        image {
            width: 40rpx;
            height: 40rpx;
            margin-right: 23rpx;
        }
    }
}
.chat-avatar {
    background-size: cover;
    text {
        width: 100%;
        line-height: 50rpx;
        text-align: center;
    }
    position: relative;
    width: 102rpx;
    height: 118rpx;
    line-height: 118rpx;
    text-align: center;
    margin: 0 auto;
    background-size: 102rpx 118rpx;
    overflow: hidden;
    image {
        position: absolute;
        top: 0;
        left: 0;
        z-index: 0;
        width: 102rpx;
        height: 118rpx;
    }
}
.users {
    height: 304rpx;
}
page,
.container {
    background: linear-gradient(0deg, #ab61ff, #df61ff);
    background-attachment: fixed;
}
.status_bar {
    height: var(--status-bar-height);
    width: 100%;
    background-color: #df61ff;
}

.top_view {
    height: var(--status-bar-height);
    width: 100%;
    position: fixed;
    top: 0;
    z-index: 999;
}
.team {
    position: fixed;
    top: 0;
    z-index: 2;
    padding: 20rpx 0 0 0;
    display: flex;
    justify-content: flex-start;
    transition: background-position 0.5s;
    .f-logo {
        margin-left: 22rpx;
        padding-left: 5rpx;
        margin-bottom: 12rpx;
        width: 108rpx;
        height: 122rpx;
        line-height: 122rpx;
        text-align: center;
        color: #ffffff;
        background-size: cover;
        display: flex;
        justify-content: center;
        position: relative;
        image {
            width: 102rpx;
            height: 118rpx;
        }
        text {
            width: 90%;
            margin: 0 auto;
            overflow: hidden;
        }
        .tip {
            position: absolute;
            bottom: 0;
            right: 0;
            z-index: 1;
            border-radius: 15rpx;
            line-height: 30rpx;
            height: 30rpx;
            width: 30rpx;
            background: #f00;
            text-align: center;
            border: 1px solid #f00;
            font-size: 16rpx;
        }
        .tip-t {
            position: absolute;
            bottom: 0;
            right: 0;
            z-index: 1;
            border-radius: 15rpx;
            line-height: 36rpx;
            height: 36rpx;
            width: 40rpx;
            background: #19c07d;
            color: #fff;
            text-align: center;
            font-size: 16rpx;
        }
    }
}

.content-top {
    padding: 0 20rpx;
    width: 100%;
    border: 0;
    view {
        border-radius: 16rpx 16rpx 0 0;
        height: 16rpx;
        background-color: #fff;
    }
}
.content {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1;
    padding: 0 20rpx 20rpx 20rpx;
    min-height: 470rpx;
    .msg-list {
        background: #ffffff;
        border-radius: 16rpx;
        padding-top: 10rpx;
    }
}
.header {
    padding: 30rpx 13rpx 20rpx 13rpx;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .right-icon {
        width: 100%;
        display: flex;
        justify-content: flex-end;
        .u-relative {
            display: flex;
            width: 50rpx;
            height: 50rpx;
            margin-right: 20rpx;
            align-items: center;
        }
        image {
            width: 48rpx;
            height: 48rpx;
        }
    }
}
.msg-list {
    width: 100%;
}
.left-head {
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    padding: 20rpx 0;
    border-bottom: 1px solid #f2e7ff;
    font-size: 30rpx;
    width: 100%;
    image {
        width: 40rpx;
        height: 40rpx;
        margin: 15rpx auto;
    }
}
.left-menu {
    display: flex;
    flex-direction: column;
    .f-logo {
        width: 102rpx;
        height: 118rpx;
        text-align: center;
        margin: 20rpx auto 0 auto;
        background-size: 102rpx 118rpx;
        overflow: hidden;
        position: relative;
        display: flex;
        justify-content: center;
        align-items: center;
        image {
            position: absolute;
            top: 0;
            left: 0;
            z-index: 0;
            width: 102rpx;
            height: 118rpx;
        }
        text {
            width: 100%;
            text-align: center;
        }
    }
    .f-list {
        width: 90%;
        padding: 20rpx 10rpx;
        text-align: left;
    }
    .active {
        color: #df61ff;
    }
}
.wx-menu {
    background-color: #fff;
    height: 90rpx;
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    position: fixed;
    z-index: 21;
    bottom: 0;
    border-top: solid 1px #ddd;
    text {
        width: 166rpx;
        height: 54rpx;
        line-height: 50rpx;
        text-align: center;
        border: 2rpx solid #d6d6d6;
        border-radius: 27rpx;
        color: #888d99;

        &.hover {
            background: #4b9cff;
            border: 2rpx solid #4b9cff;
            color: #ffffff;
        }
    }
}
.child {
    .p25 {
        padding: 25rpx 0;
        display: flex;
        align-items: center;
        font-size: 30rpx;
        color: #9da2b0;
    }
}
.down {
    transform: rotate(90deg);
    -ms-transform: rotate(90deg); /* IE 9 */
    -moz-transform: rotate(90deg); /* Firefox */
    -webkit-transform: rotate(90deg); /* Safari and Chrome */
    -o-transform: rotate(90deg); /* Opera */
}
.wdfq {
    position: fixed;
    bottom: 90rpx;
    width: 210rpx;
    padding-bottom: 20rpx;
    z-index: 100;
    background: #ffffff;
    border: 2rpx solid #4b9cff;
    box-shadow: 0px 0px 20rpx 0px rgba(75, 156, 255, 0.58);
    border-radius: 27rpx;

    view {
        display: flex;
        align-items: center;
        margin: 18rpx 20rpx 0 20rpx;
        font-size: 26rpx;
        image {
            width: 48rpx;
            height: 48rpx;
        }
    }
}
.touxiang {
    image {
        width: 115rpx;
        height: 132rpx;
        margin-right: 20rpx;
        margin-bottom: 20rpx;
    }
}

.detail {
    color: #ff9028;
}

.open-more {
    // margin-bottom: 100rpx;
    margin: 50rpx auto 0 auto;
    width: 710rpx;
    background: #ffffff;
    border-radius: 16rpx;

    .rigtfont {
        font-size: 30rpx;
        color: #9ea2b0;
    }

    .kaiqi {
        transform: scale(0.6) !important;
    }
}
.button-sub {
    width: 662rpx;
    height: 80rpx;
    font-size: 32rpx;
    margin: 50rpx auto;
    background: #ab61ff;
    border-radius: 40rpx;
    border: 0;
    color: #fff;

    &.u-hairline-border:after {
        border: 0;
    }
}
.btn-agree {
    width: 60%;
    height: 60upx;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #4b9cff;
    color: #fff;
    border-radius: 6upx;
    font-size: 28upx;
}

.view-popup {
    padding: 30upx;
}
.mark {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    z-index: 20;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}
.tagCustom {
    display: flex;
    word-wrap: break-word;
    flex-flow: wrap;
    text {
        border-radius: 30rpx;
        background: #efefef;
        padding: 10rpx 25rpx;
        margin-right: 20rpx;
        margin-bottom: 20rpx;
        &.on {
            background: #ab61ff;
            color: #fff;
        }
    }
}
.openbox {
    padding: 100rpx;
    .title {
        font-size: 36rpx;
        padding-bottom: 65rpx;
        text-align: center;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 700;
        color: #000;
    }
    .tips {
        font-size: 30rpx;
        padding-bottom: 30rpx;
        text-align: center;
    }
    .qrcode {
        width: 380rpx;
        height: 380rpx;
        margin: 0 auto;
        border: 1px solid rgba(220, 220, 220, 1);
        padding: 20rpx;
        image {
            width: 100%;
            height: 100%;
        }
    }
    .number {
        margin: 70rpx auto;
        width: 256rpx;
        height: 62rpx;
        line-height: 62rpx;
        text-align: center;
        border-radius: 12rpx;
        font-size: 30rpx;
        color: rgba(93, 98, 109, 1);
    }
}
.friend-list {
    .item {
        border-bottom: #f4f4f4 solid 1upx;
        height: 154upx;
        width: 100%;
        background-color: #fff;
        display: flex;
        align-items: center;
        padding: 0 24upx;
        justify-content: space-between;
        .center {
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            height: 100%;
            padding: 32upx 24upx;
            .title {
                color: #0e1e36;
                font-size: 30upx;
                font-weight: 500;
            }
            .tag {
                color: #6ade7e;
                border: #4ed688 solid 1upx;
                border-radius: 4px;
                width: fit-content;
                width: -webkit-fit-content;
                width: -moz-fit-content;
                padding: 5upx 12upx;
                font-size: 24upx;
                line-height: 24upx;
            }
            .tag2 {
                color: #50aafe;
                border: #50aafe solid 1upx;
            }
            .tag3 {
                color: #ff55ff;
                border: #ff55ff solid 1upx;
            }
        }
        .right {
            .btn {
                width: 153upx;
                height: 58upx;
                border: #ab62ff solid 2upx;
                color: #ab62ff;
                border-radius: 29upx;
                text-align: center;
                line-height: 58upx;
            }
        }
    }
}
.f-logo {
    width: 102rpx;
    height: 118rpx;
    display: flex;
    text-align: center;
    align-items: center;
    justify-content: center;
    background-size: auto 100%;
    background-position: center center;
    background-repeat: no-repeat;
    image {
        width: 102rpx;
        height: 118rpx;
    }
}
.tdmc {
    line-height: 70rpx;
    width: 90%;
    margin-left: 5%;
    display: flex;
    justify-content: space-between;

    text {
        font-size: 30rpx;
        color: #0d1d36;
    }

    .right {
        width: 70%;
    }

    .jine {
        font-size: 30rpx;
        color: #ab61ff;
    }
}
</style>
